fix: suggest similar projects when project not found in org (CLI-C0)#493
Merged
fix: suggest similar projects when project not found in org (CLI-C0)#493
Conversation
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.
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ❌ Patch coverage is 60.00%. Project has 1056 uncovered lines. Files with missing lines (1)
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
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
This was referenced Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: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:Design Decisions
findSimilarProjectscatches all errors and returns empty array on failure — the error message still works without suggestions