Commit 830f455
authored
fix(json): flatten view command JSON output for --fields filtering (#495)
## Summary
`issue view`, `event view`, and `trace view` commands yielded wrapper
objects (e.g., `{ issue, event, trace }`) as their `CommandOutput` data.
When `--fields` was used, `filterFields` looked for field names at the
top level of this wrapper, so `--fields shortId,title` returned `{}`
because those fields lived inside the nested `issue` object.
## Fix
Add `jsonTransform` to all three view commands that spreads the primary
entity as the top-level object:
- **issue view**: `{ ...issue, event, trace }`
- **event view**: `{ ...event, trace }`
- **trace view**: `{ ...summary, spans }`
This makes `--fields shortId,title` work directly on issue properties,
while enrichment data remains accessible via `--fields event.id` or
`--fields trace.traceId`.
## Test plan
- `bun test test/commands/trace/view.func.test.ts` — updated assertions
for flattened JSON structure
- Manual: `sentry issue view <id> --json --fields shortId,title,count`
should return filtered fields instead of `{}`1 parent da74739 commit 830f455
File tree
6 files changed
+116
-50
lines changed- src/commands
- event
- issue
- trace
- test
- commands/trace
- e2e
6 files changed
+116
-50
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
80 | 102 | | |
81 | 103 | | |
82 | 104 | | |
| |||
387 | 409 | | |
388 | 410 | | |
389 | 411 | | |
390 | | - | |
| 412 | + | |
391 | 413 | | |
392 | 414 | | |
393 | 415 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
87 | 112 | | |
88 | 113 | | |
89 | 114 | | |
| |||
104 | 129 | | |
105 | 130 | | |
106 | 131 | | |
107 | | - | |
| 132 | + | |
108 | 133 | | |
109 | 134 | | |
110 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
120 | 143 | | |
121 | 144 | | |
122 | 145 | | |
| |||
130 | 153 | | |
131 | 154 | | |
132 | 155 | | |
133 | | - | |
| 156 | + | |
134 | 157 | | |
135 | 158 | | |
136 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
| 179 | + | |
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
| |||
0 commit comments