Commit 23cb92c
fix(project): fallback to org listing when bare slug matches an organization (#475)
## Summary
`sentry project list acme-corp` throws a `ResolutionError` when
`acme-corp` is an organization slug, not a project. Users naturally type
the org name as the argument expecting to see their projects listed.
The shared `handleProjectSearch` in `org-list.ts` already handles this —
it checks if the bare slug matches an org and falls back gracefully. But
the project list command has its own custom `handleProjectSearch` that
skipped this check.
> **Note:** `sentry project list` (no args) already works fine for
single-org users via auto-detect. This fix covers the case where users
explicitly pass their org name as the argument.
## Before / After
### Before
```
$ sentry project list acme-corp
✘ Project 'acme-corp' not found.
Try:
sentry project list <org>/acme-corp
Or:
- No project with this slug found in any accessible organization
```
### After
```
$ sentry project list acme-corp
⚠ 'acme-corp' is an organization, not a project. Listing all projects in 'acme-corp'.
Slug Platform
──────────── ──────────────
frontend javascript
backend python
mobile-ios apple-ios
```
## Resolution flow
```
sentry project list <arg>
│
▼
parseOrgProjectArg(arg)
│
├─ no arg ──────────► auto-detect (DSN/config/all-orgs) ✅ already works
├─ "acme-corp/" ────► org-all: list projects in org ✅ already works
├─ "acme-corp/web" ─► explicit: fetch specific project ✅ already works
└─ "acme-corp" ────► project-search mode
│
▼
findProjectsBySlug("acme-corp")
│
├─ project found ──► show it ✅ already works
└─ no project found
│
▼
slug matches an org? ◄── this is the fix
│
├─ yes ──► warn + fallback to handleOrgAll ✅ NEW
└─ no ───► ResolutionError (not found) (unchanged)
```
## Test plan
- [x] `bun run typecheck` passes
- [x] `bun run lint` passes
- [x] All 59 project list tests pass (`bun test
test/commands/project/list.test.ts`)
Fixes https://sentry.sentry.io/issues/7346957149/
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent b7b240e commit 23cb92c
1 file changed
+31
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
| |||
507 | 510 | | |
508 | 511 | | |
509 | 512 | | |
510 | | - | |
| 513 | + | |
511 | 514 | | |
512 | 515 | | |
513 | 516 | | |
| |||
523 | 526 | | |
524 | 527 | | |
525 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
526 | 549 | | |
527 | 550 | | |
528 | 551 | | |
| |||
581 | 604 | | |
582 | 605 | | |
583 | 606 | | |
584 | | - | |
| 607 | + | |
| 608 | + | |
585 | 609 | | |
586 | 610 | | |
587 | 611 | | |
588 | | - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
589 | 617 | | |
590 | 618 | | |
591 | 619 | | |
| |||
0 commit comments