Skip to content

fix(resolve): guide users to org/project instead of silencing the auto-detect error (CLI-3B)#1155

Open
BYK wants to merge 2 commits into
mainfrom
byk/fix/org-project-autodetect-ux
Open

fix(resolve): guide users to org/project instead of silencing the auto-detect error (CLI-3B)#1155
BYK wants to merge 2 commits into
mainfrom
byk/fix/org-project-autodetect-ux

Conversation

@BYK

@BYK BYK commented Jun 27, 2026

Copy link
Copy Markdown
Member

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.

…o-detect error (CLI-3B)

"Could not auto-detect organization and project" was being silenced, which hid
the signal AND skipped the underlying UX fix. Instead of dropping it, help users
succeed and keep the error visible to measure the impact:

- Sole-account auto-select: when an authenticated account has exactly one
  accessible org with exactly one project, resolveOrgAndProject now returns that
  pair instead of null (step 7 of the cascade). This is strictly additive —
  callers that depend on a null return (e.g. event view's cross-org search) are
  unaffected, since it only turns a null into a uniquely-determined target.

- Interactive picker: on a failed auto-detect in a TTY, guideOrgProjectFailure
  prompts the user to choose an org/project and saves it as the default. Gated
  on stdin AND stdout being TTYs so piped/--json runs never block.

- Enriched error: authenticated users who can't be auto-resolved get a
  ContextError listing their accessible orgs (copy-pasteable), instead of the
  generic "run org list" guidance.

- Un-silence ContextError: reverted the classifySilenced ContextError branch
  (and the dead recordSilencedError resource attribute) so its volume stays
  visible as the signal for these UX improvements.

Wired into the auto-detect paths of resolveOrgProjectTarget,
resolveTargetsFromParsedArg (issue list), and trace-target. Upload commands get
the sole-account auto-select for free via resolveOrgAndProject.
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Jun 27, 2026
@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1155/

Built to branch gh-pages at 2026-06-27 15:24 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/lib/resolve-target.ts
Comment thread src/lib/resolve-target.ts Outdated
Comment thread src/lib/resolve-target.ts
@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

❌ Patch coverage is 51.14%. Project has 5157 uncovered lines.
❌ Project coverage is 81.44%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/lib/resolve-target.ts 48.19% ⚠️ 43 Missing and 6 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    81.48%    81.44%    -0.04%
==========================================
  Files          397       398        +1
  Lines        27702     27780       +78
  Branches     17991     18048       +57
==========================================
+ Hits         22570     22623       +53
- Misses        5132      5157       +25
- Partials      1862      1872       +10

Generated by Codecov Action

…rompts in JSON mode

Cursor Bugbot review on #1155:

- HIGH: when auto-detect found DSNs but none resolved (self-hosted/no access),
  resolveTargetsFromParsedArg now preserves the empty result + skippedSelfHosted
  instead of calling the guide, so issue list surfaces the inaccessible-DSN
  ContextError rather than silently resolving a different org/project.

- MEDIUM: added a process-wide interactive-prompts gate (interactive-prompts.ts)
  that the command wrapper disables in JSON mode; canPromptForTarget now consults
  it, so --json runs never block on or interleave with the org/project picker.

- LOW (Seer): documented that guideOrgProjectFailure can also throw
  ResolutionError (selected org has no accessible projects).
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: medium PR risk score: medium labels Jun 27, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7abe866. Configure here.

Comment thread src/lib/telemetry.ts
// ApiError) are expected states — marking them crashed would skew
// release-health.
// Silenced errors (OutputError, expected AuthError, user 4xx ApiError) are
// expected states — marking them crashed would skew release-health.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ContextError marks sessions crashed

Medium Severity

Stopping silencing of ContextError for issue reporting also causes withTelemetry to call markSessionCrashed, because session handling reuses classifySilenced. Missing org/project and similar user-context failures are now counted as crashed CLI sessions, which skews release-health metrics for a large expected-error class.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7abe866. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant