You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(arg-parsing): accept underscores in Sentry slugs (#770) (#771)
## Summary
Fixes#770. The CLI was converting underscores to dashes in
`normalizeSlug()` on the assumption that "Sentry slugs never contain
underscores". That assumption is wrong — the Sentry platform accepts
underscores in project slugs at creation time, and rewriting them at the
CLI layer made it impossible for affected customers to look up their own
projects.
## Verification
Live API test against a real org before the fix:
```
$ sentry api --method POST /teams/byk-test/byk-test/projects/ \
--field slug=test_underscore_slug \
--field name=test_underscore_project \
--field platform=javascript
# → 200 OK, slug preserved exactly as "test_underscore_slug"
$ sentry api /projects/byk-test/test_underscore_slug/
# → 200 OK, round-trips cleanly
```
Before (the bug):
```
$ sentry issue list byk-test/test_underscore_slug
[arg-parsing] WARN Normalized slug to 'byk-test/test-underscore-slug' (Sentry slugs use dashes, never underscores)
Error: Project 'test-underscore-slug' not found in organization 'byk-test'.
```
After this PR (running the dev build against the same project):
```
$ bun run dev issue list byk-test/test_underscore_slug
No issues found.
```
Space normalization still works as before:
```
$ bun run dev issue list "BYK Test/My Project"
[arg-parsing] WARN Normalized slug to 'byk-test/my-project' (Sentry slugs use lowercase with dashes, not spaces)
```
## History (for reviewers)
- The underscore rule was introduced in #363 as typo-correction for one
specific customer (`selfbase_admin_backend`), never verified against the
platform.
- #757 folded underscore and space handling into a combined `[_ ]+`
regex. The reporter on #770 correctly spotted that regex — but the root
cause predates that PR.
- The legacy `sentry-cli` (Rust) accepts underscored slugs, so the new
CLI diverging on this is a regression from the user's perspective.
## Changes
- `normalizeSlug()`: only normalize when the input contains a space.
Underscored input is returned unchanged (`normalized: false`).
- Remove the `NormalizeReason` discriminator. With underscores gone,
only the "spaces" path remains, so `reason` collapses to `normalized:
true` (and the warning message becomes a single string).
- `ParsedOrgProject`: drop the `reason?` field from all three variants.
- `trace-target.ts`: no source change required — already only read
`.slug` and `.normalized`.
- Tests: replace underscore-normalization tests with
underscore-preservation tests. Mixed inputs like `my_org/My Project` now
correctly yield `{ org: "my_org", project: "my-project" }`. Delete the
three command-level underscore-warning tests (the code path no longer
exists; unit-level space coverage is sufficient).
## Verification
- `bun run typecheck` — clean
- `bun run lint` — clean (pre-existing warning in `markdown.ts`
unrelated)
- `bun run test:unit` — 5036 / 5036 pass
- `bun run test:isolated` — 138 / 138 pass
- `bun run check:errors`, `bun run check:deps` — clean
- Manual end-to-end repro against real Sentry org (above).
Net diff: −110 lines.
0 commit comments