Skip to content

fix: suggest similar projects when project not found in org (CLI-C0)#493

Merged
BYK merged 1 commit intomainfrom
fix/cli-c0-project-not-found
Mar 20, 2026
Merged

fix: suggest similar projects when project not found in org (CLI-C0)#493
BYK merged 1 commit intomainfrom
fix/cli-c0-project-not-found

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Mar 20, 2026

Problem

When users specify an explicit org/project (e.g., sentry issue list elide/elide-server) and the project isn't found, the error only says:

Project 'elide-server' not found in organization 'elide'.

Try:
  sentry issue list elide/<project>

Or:
  - Check the project slug at https://sentry.io/organizations/elide/projects/

This affects 36 users (CLI-C0). Users don't know what the correct project slug is.

Fix

Added a findSimilarProjects() helper that, on 404, lists available projects in the org and finds similar slugs using case-insensitive prefix/substring matching. Now the error includes suggestions:

Project 'elide-server' not found in organization 'elide'.

Try:
  sentry issue list elide/<project>

Or:
  - Similar projects: 'elide-api-server', 'elide-web'
  - Check the project slug at https://sentry.io/organizations/elide/projects/

Design Decisions

  • Best-effort: findSimilarProjects catches all errors and returns empty array on failure — the error message still works without suggestions
  • Lightweight matching: Uses case-insensitive prefix/substring scoring (no heavy fuzzy matching library needed). Scores: exact case-insensitive match (3) > prefix match (2) > substring match (1)
  • Limited results: Returns at most 3 similar slugs to keep the error message readable
  • Non-blocking: Only runs on 404 errors, not on every project fetch

When users specify an explicit org/project (e.g., sentry issue list
elide/elide-server) and the project isn't found, the error now suggests
similar project slugs from the org. This helps users who misspell slugs
or use wrong casing (CLI-C0, 36 users).

Added findSimilarProjects() that uses case-insensitive prefix/substring
matching to find up to 3 similar slugs. Falls back gracefully on API
errors since it's a best-effort hint. Suggestions appear before the
existing project-settings URL link.
@github-actions
Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (telemetry) Track TTY vs non-TTY invocations via metric by betegon in #482
  • Dynamic cache-backed shell completions with fuzzy matching by BYK in #465

Bug Fixes 🐛

  • (project) Fallback to org listing when bare slug matches an organization by betegon in #475
  • Suggest similar projects when project not found in org (CLI-C0) by BYK in #493
  • Event 404 hint should suggest different project, not repeat failing command by BYK in #492
  • Enrich event 404 errors with retention and format suggestions (CLI-6F) by BYK in #491
  • Add actionable suggestions for 400 Bad Request on issue list (CLI-BM, CLI-7B) by BYK in #489
  • Detect issue short IDs passed to issue list (CLI-C3) by BYK in #488
  • Add Glob.match() polyfill + improve auto-detect diagnostics (CLI-7T) by BYK in #487
  • Add org-slug pre-check to dispatchOrgScopedList (CLI-9A) by BYK in #485

Internal Changes 🔧

  • (issue) Skip getProject round-trip in project-search resolution by betegon in #473
  • (resolve) Carry project data through resolution to eliminate redundant getProject calls by BYK in #486
  • HTTP latency optimizations — diagnostics, cache warming, concurrency limits by BYK in #490
  • Switch from @sentry/bun to @sentry/node-core/light (~170ms startup savings) by BYK in #474
  • Regenerate skill files by github-actions[bot] in b7b240ec

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

Codecov Results 📊

126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 60.00%. Project has 1056 uncovered lines.
❌ Project coverage is 95.72%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
resolve-target.ts 82.01% ⚠️ 131 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    95.77%    95.72%    -0.05%
==========================================
  Files          180       180         —
  Lines        24622     24654       +32
  Branches         0         0         —
==========================================
+ Hits         23580     23598       +18
- Misses        1042      1056       +14
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK merged commit 0714d27 into main Mar 20, 2026
22 checks passed
@BYK BYK deleted the fix/cli-c0-project-not-found branch March 20, 2026 01:04
BYK added a commit that referenced this pull request Mar 20, 2026
…I-C0)

Improves the 'project not found' error from PR #493:

1. Replace ad-hoc prefix/substring scoring in findSimilarProjects with
   the shared fuzzyMatch utility from src/lib/fuzzy.ts. This adds
   Levenshtein distance matching so typos like 'senry' → 'sentry' are
   caught, while keeping the same prefix and substring matching.

2. Change the primary 'Try:' hint from a settings URL to the more
   actionable 'sentry project list <org>/' command that users can
   run directly in their terminal.

3. Add two new tests covering the 404 suggestion paths:
   - Similar projects found: verifies fuzzy-matched slugs appear in error
   - listProjects fails: verifies the project list command still appears

Addresses review feedback on PR #493 (low patch coverage, missing fuzzy
matching, should suggest project list command).
BYK added a commit that referenced this pull request Mar 20, 2026
…I-C0) (#504)

## Follow-up to PR #493

Addresses review feedback on [PR
#493](#493):

1. **Low patch coverage** → Added 2 new tests covering the
similar-project suggestion paths
2. **Should suggest `sentry project list`** → Changed primary hint from
settings URL to `sentry project list <org>/`
3. **Should use existing fuzzy matching** → Replaced ad-hoc
prefix/substring scoring with the shared `fuzzyMatch` utility

## Changes

### `src/lib/resolve-target.ts`

**`findSimilarProjects`**: Replaced 15-line ad-hoc scoring with 3-line
delegation to `fuzzyMatch()`:
```typescript
const slugs = projects.map((p) => p.slug);
return fuzzyMatch(slug, slugs, { maxResults: 3 });
```

This adds **Levenshtein distance matching** for typos (e.g., `senry` →
`sentry`) while keeping the same prefix/substring matching from before.

**`fetchProjectId` suggestions**: Reordered to lead with the actionable
CLI command:
```
Or:
  - Similar projects: 'test-project-api', 'test-project-web'
  - List available projects: sentry project list my-org/
  - Check the project slug at https://sentry.io/organizations/my-org/projects/
```

### `test/lib/resolve-target.test.ts`

Two new tests:
- **`includes similar project suggestions on 404 when projects exist`**
— Mocks getProject→404 + listProjects→project list, verifies fuzzy
matches appear and unrelated projects are excluded
- **`includes project list suggestion even when listProjects fails`** —
Mocks all requests→404, verifies the `sentry project list` fallback
still appears
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant