fix: improve error messages — fix ContextError/ResolutionError misuse#456
Merged
fix: improve error messages — fix ContextError/ResolutionError misuse#456
Conversation
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
707a57c to
b992f50
Compare
Contributor
Codecov Results 📊✅ 116 passed | Total: 116 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 97.80%. Project has 1139 uncovered lines. Files with missing lines (4)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.19% 95.20% +0.01%
==========================================
Files 175 175 —
Lines 23699 23729 +30
Branches 0 0 —
==========================================
+ Hits 22560 22590 +30
- Misses 1139 1139 —
- Partials 0 0 —Generated by Codecov Action |
Fix the 'Try: ... Or: ...' error message pattern that produced confusing output for hundreds of users (CLI-7V: 127 events, CLI-4A: 21 events, etc). Problems fixed: - ContextError misused for resolution failures, producing messages like 'Project is required. Specify it using: No project found...' - Grammar: 'Trace ID and span ID is required' → 'are required' - Irrelevant DSN/project alternatives shown for missing positional IDs - Ad-hoc 'Try:' strings in raw CliError bypassing structured errors - Pagination cursor using ContextError instead of ValidationError - event view throwing confusing error for issue URLs (now fetches latest event) Prevention measures: - Runtime assertion in ContextError constructor: command must be single-line - CI check script (check:errors) scanning for multiline ContextError commands and ad-hoc 'Try:' patterns in CliError - Improved JSDoc explaining when to use ContextError vs ResolutionError - AGENTS.md updated with error class selection guidance Fixes CLI-7V, CLI-4A, CLI-EZ, CLI-CC, CLI-DQ
b992f50 to
5704b5e
Compare
5 tasks
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
The
ContextErrorandResolutionErrorclasses produce structuredTry: ... Or: ...error messages, but they're misused in ~15 call sites, producing confusing output. Real Sentry issues confirm this affects hundreds of users:Project is required. Specify it using: No project 'patagonai' found...Project 'AGENT-API' not found is required.Trace ID and span ID is required.(grammar) + irrelevant DSN alternativesChanges
Error class fixes:
"X and Y is required"→"are required"for compound resourcesContextErrormisuses toResolutionError(org-list, project/list, issue/list, project/create, resolve-team, project/view, resolve-target)ValidationErroralternatives: []at 14 sites where DSN hints are irrelevant (Trace ID, Log ID, Event ID, Span ID)event view enhancement:
/issues/123/) now fetch the latest event viagetLatestEvent()instead of throwing a confusing error about missing event IDsPrevention measures:
ContextErrorconstructor:commandmust be single-line (throws on\n)script/check-error-patterns.ts) scanning for multiline ContextError commands and ad-hocTry:patterns inCliErrorcheck:errorsstep to CI workflowFixes CLI-7V, CLI-4A, CLI-EZ, CLI-CC, CLI-DQ