Commit 8aa9cf6
authored
feat(args): parse Sentry web URLs as CLI arguments (#252)
## Summary
- Users can now paste Sentry web URLs directly as CLI arguments (e.g.,
`sentry issue view
https://sentry.example.com/organizations/my-org/issues/32886/?project=2`)
instead of manually extracting org/project/issue IDs
- Supports both SaaS (sentry.io) and self-hosted instances — self-hosted
URLs automatically configure `SENTRY_URL` for the session
- Fixes frozen module-level constants in `oauth.ts` and
`sentry-client.ts` that prevented dynamic URL detection from working
## URL Patterns Supported
| Pattern | Used By |
|---------|---------|
| `/organizations/{org}/issues/{id}/` | `issue view`, `issue explain`,
`issue plan` |
| `/organizations/{org}/issues/{id}/events/{eventId}/` | `event view` |
| `/settings/{org}/projects/{project}/` | `project view`, `project list`
|
| `/organizations/{org}/traces/{traceId}/` | `trace view` |
| `/organizations/{org}/` | org-scoped commands |
## Changes
### New Files
- **`src/lib/sentry-url-parser.ts`** — Pure URL parser
(`parseSentryUrl`) + self-hosted env config (`applySentryUrlContext`)
- **`test/lib/sentry-url-parser.test.ts`** — 30 unit tests covering all
URL patterns, edge cases, and env var behavior
- **`test/lib/sentry-url-parser.property.test.ts`** — Round-trip
property tests verifying URLs built by `sentry-urls.ts` can be parsed
back
### Modified Files
- **`src/lib/arg-parsing.ts`** — URL pre-parsing in `parseIssueArg()`
and `parseOrgProjectArg()`
- **`src/commands/event/view.ts`** — URL handling in
`parsePositionalArgs()` for event URLs
- **`src/lib/oauth.ts`** — Replaced frozen `const SENTRY_URL` with lazy
`getSentryUrl()` function
- **`src/lib/sentry-client.ts`** — Removed frozen `const
CONTROL_SILO_URL`, made `getControlSiloUrl()` read env var lazily
### Test Updates
- **`test/lib/arg-parsing.test.ts`** — Added URL integration tests for
both parsers
- **`test/commands/event/view.test.ts`** — Added event URL handling
tests
## Fixes
Resolves CLI-66 (self-hosted users get confusing errors when pasting
URLs)1 parent b138f02 commit 8aa9cf6
File tree
9 files changed
+929
-18
lines changed- src
- commands/event
- lib
- test
- commands/event
- lib
9 files changed
+929
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| |||
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
67 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
68 | 82 | | |
69 | 83 | | |
70 | 84 | | |
| |||
81 | 95 | | |
82 | 96 | | |
83 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
84 | 115 | | |
85 | 116 | | |
86 | 117 | | |
| |||
181 | 212 | | |
182 | 213 | | |
183 | 214 | | |
184 | | - | |
185 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
186 | 220 | | |
187 | 221 | | |
188 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| |||
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
99 | 150 | | |
100 | 151 | | |
101 | 152 | | |
102 | 153 | | |
103 | 154 | | |
| 155 | + | |
104 | 156 | | |
105 | 157 | | |
106 | 158 | | |
| |||
123 | 175 | | |
124 | 176 | | |
125 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
126 | 185 | | |
127 | 186 | | |
128 | 187 | | |
| |||
287 | 346 | | |
288 | 347 | | |
289 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
290 | 364 | | |
291 | 365 | | |
292 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
20 | 28 | | |
21 | 29 | | |
22 | 30 | | |
| |||
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
85 | | - | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
| |||
103 | 111 | | |
104 | 112 | | |
105 | 113 | | |
106 | | - | |
| 114 | + | |
107 | 115 | | |
108 | 116 | | |
109 | 117 | | |
| |||
146 | 154 | | |
147 | 155 | | |
148 | 156 | | |
149 | | - | |
| 157 | + | |
150 | 158 | | |
151 | 159 | | |
152 | 160 | | |
| |||
332 | 340 | | |
333 | 341 | | |
334 | 342 | | |
335 | | - | |
| 343 | + | |
336 | 344 | | |
337 | 345 | | |
338 | 346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 15 | | |
22 | 16 | | |
23 | 17 | | |
| |||
291 | 285 | | |
292 | 286 | | |
293 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
294 | 291 | | |
295 | 292 | | |
296 | | - | |
| 293 | + | |
297 | 294 | | |
298 | 295 | | |
299 | 296 | | |
| |||
339 | 336 | | |
340 | 337 | | |
341 | 338 | | |
342 | | - | |
| 339 | + | |
343 | 340 | | |
344 | 341 | | |
345 | 342 | | |
| |||
0 commit comments