This repository was archived by the owner on Oct 23, 2026. It is now read-only.
Repository navigation
fix(error-reporting): silence ContextError to stop crash reports (CLI-3B) - #1149
Merged
Merged
Conversation
) ContextError is thrown when the user omits a required value — no org/project could be auto-detected, a required ID was not provided, etc. It is an expected user-input error, never a CLI bug, yet it was still reported to Sentry as an unhandled crash. This made it the single highest-volume issue (CLI-3B: ~2000 users / ~9000 events, plus CLI-CG, CLI-1BC, CLI-1BD). Classify ContextError as silenced in classifySilenced, mirroring the existing OutputError / expected-AuthError / 4xx-ApiError rules. Volume is preserved via the cli.error.silenced metric, now enriched with the ContextError resource so the missing value (e.g. "Organization and project" vs "Event ID") keeps sub-grouping context. Unlike ResolutionError — where a provided-but-unmatched value can signal a product/access issue worth observing — ContextError has nothing per-instance to investigate, so the whole class is silenced. Silenced errors also no longer mark the session as crashed, which keeps release-health from being skewed by missing-input errors.
Contributor
|
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 5133 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 81.53% 81.46% -0.07%
==========================================
Files 397 397 —
Lines 27682 27686 +4
Branches 17968 17972 +4
==========================================
+ Hits 22570 22553 -17
- Misses 5112 5133 +21
- Partials 1867 1861 -6Generated by Codecov Action |
BYK
added a commit
that referenced
this pull request
Jul 14, 2026
…o-detect error (#1155) ## Why Follow-up to #1149 based on review feedback: **"Could not auto-detect organization and project" was being silenced, which hid the signal AND skipped the underlying UX fix.** We keep these errors around to learn where users get stuck — so the right move is to help users succeed *and* keep the error visible to measure impact. CLI-3B: ~2000 users. ## What changed **1. Sole-account auto-select (helps every command, zero risk)** `resolveOrgAndProject` gains a final cascade step: when an authenticated account has exactly **one** accessible org with exactly **one** project, that pair is the only possible answer, so it's returned instead of `null`. This is strictly additive — callers that depend on a `null` return (notably `event view`'s cross-org search) are unaffected, since it only ever turns a `null` into a uniquely-determined target. **2. Interactive picker (TTY)** On a failed auto-detect, `guideOrgProjectFailure` prompts the user to choose an org then a project, and saves the choice as the default (so they're not asked again). Gated on **both** stdin and stdout being TTYs, so piped/`--json` invocations never block on a prompt. **3. Enriched error** Authenticated users who still can't be resolved get a `ContextError` listing their accessible orgs (copy-pasteable), instead of the generic "run `sentry org list`" guidance shown to logged-out users. **4. Un-silence `ContextError`** Reverted the `classifySilenced` `ContextError` branch (and the now-dead `recordSilencedError` resource attribute) so its volume stays visible — that volume is the signal for whether the UX changes above actually work. ## Wiring `guideOrgProjectFailure` is invoked on the auto-detect failure path of `resolveOrgProjectTarget`, `resolveTargetsFromParsedArg` (backs `issue list`), and `trace-target`. The fallback is kept **separate** from `resolveOrgAndProject` (rather than wrapping it) so command tests that mock the resolver — and rely on its `null` return — keep working; the guide only runs on the explicit failure path. Upload commands (`sourcemap`/`debug-files`/`proguard`/`code-mappings`/`dart-symbol-map`) get the sole-account auto-select for free via `resolveOrgAndProject`; their interactive-picker/enriched-error wiring can follow up (they're usually non-interactive CI runs with DSN/config context). ## Tests - `resolveOrgProjectOrGuide`: sole-org/project auto-select, multi-org enriched `ContextError`, unauthenticated generic `ContextError` (no org-list call). - Updated `classifySilenced` / `recordSilencedError` / telemetry tests to assert `ContextError` is now **captured**, not silenced. - Updated trace/span resolver tests for the new fallback path. - Full `test/lib` + `test/commands` suites green (7964 passing); lint + typecheck clean.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
ContextErroris thrown when the user omits a required value — noorg/project could be auto-detected, a required ID was not provided, etc. It is
an expected user-input error (per
AGENTS.md: "User omitted a required value →ContextError"), yet it was still reported to Sentry as an unhandled crash.
That made it the single highest-volume issue in the project:
Fix
Classify
ContextErroras silenced inclassifySilenced, mirroring theexisting
OutputError/ expected-AuthError/ 401–499ApiErrorrules:cli.error.silencedmetric, now enriched with theContextError.resourceso the missing value (e.g."Organization and project"vs"Event ID") keeps sub-grouping context.resourcevalues are asmall fixed set, so metric cardinality stays low.
errors stop skewing release-health.
Why the whole class (vs. opt-in like ResolutionError)
ContextErroralways means "you didn't provide X" — there is nothingper-instance to investigate. This differs from
ResolutionError, where aprovided value that can't be matched may signal a product/access issue worth
observing (which is why that class is silenced opt-in). The
cli.error.silencedmetric still records the volume and which value was missing.
Test plan
classifySilencedtests updated:ContextErrornow asserts"context_missing"(removed from the "does NOT silence" list).
reportCliErrorintegration:ContextErrornow asserts nocaptureExceptioncli.error.silencedmetric carryingerror_class,reason,resource.telemetrytest updated:ContextErroris silenced and does not mark thesession crashed.
vitest run test/lib/error-reporting.test.ts test/lib/telemetry.test.ts→ 183 passedbiome checkclean on changed filesFixes CLI-3B