Skip to content

fix: guard against null status in seer API, plan command, and monitor schedule formatting - #1104

Merged
jared-outpost[bot] merged 7 commits into
mainfrom
cursor/sentry-cli-bug-fixes-4fe7
Sep 28, 2026
Merged

jared-outpost[bot] merged 7 commits into
mainfrom
cursor/sentry-cli-bug-fixes-4fe7

Conversation

@cursor

@cursor cursor Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Three independent bug fixes for crashes and logic errors found via codebase analysis and issue triage.


Fix 1: normalizeAgentStatus TypeError on null/undefined status

Root cause: normalizeAgentStatus() in src/lib/api/seer.ts calls status.toUpperCase() in its default branch, which throws TypeError when the Seer API returns an autofix state with a null or missing status field (e.g. a freshly created run).

Reproduction: Call sentry issue explain or sentry issue plan against an issue where the autofix API response has autofix.status as null or undefined.

Fix: Added a null/undefined guard that defaults to "PROCESSING" — matching the initial state of a new autofix run.


Fix 2: plan command proceeds to solution planning when root cause needs user input (GitHub #958)

Root cause: When ensureRootCauseAnalysis returns with WAITING_FOR_USER_RESPONSE status (user needs to select a root cause in the Sentry web UI), the plan command proceeds to call triggerSolutionPlanning anyway, causing confusing failures or empty results.

Reproduction: Run sentry issue plan <issue> on an issue where root cause analysis is waiting for user input to select a root cause.

Fix: Added a status check after ensureRootCauseAnalysis that throws a clear CliError directing the user to the Sentry UI. Also added a WAITING_FOR_USER_RESPONSE check after solution polling to avoid the misleading "could not identify a code fix" message.


Fix 3: formatSchedule unguarded array access in monitor list

Root cause: formatSchedule() in src/commands/monitor/list.ts accesses config.schedule[0] and config.schedule[1] without checking array length, producing "every undefined undefined" for empty or single-element schedule arrays.

Reproduction: sentry monitor list against an org with a monitor whose interval schedule array has fewer than 2 elements.

Fix: Added a schedule.length < 2 guard that falls back to stringifying the first element for malformed arrays.

Open in Web View Automation 

cursoragent and others added 3 commits June 15, 2026 12:14
When the Seer API returns an autofix state with a null or missing status
field, normalizeAgentStatus() would call status.toUpperCase() on the
default branch, throwing a TypeError. This can happen when an autofix
run is freshly created and has not yet received a status update.

Default to 'PROCESSING' when status is falsy, matching the initial
state of a new autofix run.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
When ensureRootCauseAnalysis returns with WAITING_FOR_USER_RESPONSE
status (meaning the user needs to select a root cause in the Sentry
web UI), the plan command would proceed to call triggerSolutionPlanning
anyway. This causes confusing failures or empty results.

Now checks the state status after root cause analysis completes and
throws a clear CliError directing the user to the Sentry UI. Also
handles WAITING_FOR_USER_RESPONSE during solution polling to avoid
the misleading 'could not identify a code fix' message.

Relates to GitHub issue #958.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
When a monitor's interval schedule array has fewer than 2 elements
(e.g. an empty array or single-element array from a misconfigured
monitor), the formatter would produce 'every undefined undefined'
in the SCHEDULE column.

Added a length check before accessing schedule[0] and schedule[1],
falling back to stringifying the first element for short arrays.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
@github-actions

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-1104/

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

@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

❌ Patch coverage is 12.50%. Project has 5021 uncovered lines.
❌ Project coverage is 81.17%. Comparing base (base) to head (head).

Files with missing lines (3)
File Patch % Lines
src/commands/issue/plan.ts 0.00% ⚠️ 4 Missing
src/commands/monitor/list.ts 0.00% ⚠️ 2 Missing
src/lib/api/seer.ts 50.00% ⚠️ 1 Missing and 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    81.19%    81.17%    -0.02%
==========================================
  Files          383       383         —
  Lines        26651     26659        +8
  Branches     17354     17364       +10
==========================================
+ Hits         21638     21638         —
- Misses        5013      5021        +8
- Partials      1798      1802        +4

Generated by Codecov Action

@github-actions github-actions Bot added the risk: low PR risk score: low label Sep 21, 2026
Comment thread packages/cli/src/commands/issue/plan.ts
@BYK BYK added the jared Trigger the Jared agent to work on stuff label Sep 21, 2026
@BYK

BYK commented Sep 21, 2026

Copy link
Copy Markdown
Member

Jared, can you take over this PR, resolve merge conflicts and address my comment?

@MathurAditya724

Copy link
Copy Markdown
Member

Jared, resolve the messages by byk and the merge issues

Bring the branch up to date with the monorepo restructure (src/ ->
packages/cli/src/). The three fixes reapply cleanly onto the new layout.
When root cause analysis pauses on WAITING_FOR_USER_RESPONSE, interactive
sessions now present the candidate root causes and let the user pick one in
the terminal so planning can continue, instead of always erroring out. JSON
output and non-TTY runs keep the clear Sentry-UI hint.

Addresses BYK's review feedback on #1104.
@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Sep 28, 2026 5:33pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Sep 28, 2026 5:33pm UTC

Request Review

@jared-outpost

jared-outpost Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

done on both fronts.

merge issues — the branch had drifted behind main's monorepo restructure (src/ → packages/cli/src/), which is why it showed as conflicting. i merged latest main in; all three fixes reapply cleanly onto the new layout and the PR is now MERGEABLE.

byk's review — his ask was "instead of throwing, can we not get the user input here in the terminal?" on the WAITING_FOR_USER_RESPONSE branch in issue plan. done in 9be98b1: interactive TTY runs now list the candidate root causes and let you pick one in the terminal, then continue to solution planning. JSON/non-TTY runs keep the clear "open the issue in Sentry" error so scripted usage never blocks. added plan.func.test.ts covering the interactive, non-interactive, and cancel paths. typecheck, lint, and issue-command tests are green. i replied on his thread and resolved it.

@BYK
BYK marked this pull request as ready for review September 28, 2026 16:27
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: low PR risk score: low labels Sep 28, 2026
@jared-outpost

jared-outpost Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

not enabling auto-merge here — the diff is 188 lines changed across 4 files (over the 150-line auto-merge threshold, mostly the new plan.func.test.ts), and it's tagged risk: medium. leaving it for a human to merge. it's approved and CI is green, so should be good to go whenever you're ready.

Comment thread packages/cli/src/commands/issue/plan.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor Author

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.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9be98b1. Configure here.

Comment thread packages/cli/src/commands/issue/plan.ts
@BYK

BYK commented Sep 28, 2026

Copy link
Copy Markdown
Member

Jared, fix all Seer and Cursor findings, get the patch coverage above 80% and then you can merge if there are no more comments after that round.

The interactive prompt captured the user's selection but never submitted it,
then advanced a run still in WAITING_FOR_USER_RESPONSE — flagged by Seer and
Cursor review. Sentry has no CLI-facing endpoint to submit a specific cause_id
(root-cause selection among candidates happens in the web UI), so make this a
confirm-to-continue: show the identified root cause, ask whether to plan, and
only then advance via triggerSolutionPlanning (the same step the Sentry UI
uses). Declining or a non-TTY/JSON run keeps the clear Sentry-UI error.

Add coverage: interactive confirm/decline/cancel, post-planning terminal
states, existing-solution short-circuit, normalizeAgentStatus null guard, and
formatSchedule edge cases.
@jared-outpost

jared-outpost Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

the bugbot finding (root cause selection never submitted) is fixed in 4a9c354 — same fix as the inline threads, which are now resolved. the captured selection was being discarded; since Sentry has no CLI-facing endpoint to submit a specific cause_id, this is now a confirm-to-continue that advances the run via triggerSolutionPlanning (the same step the web UI uses), with the open-in-Sentry error retained for non-interactive/JSON runs. covered by new confirm/decline/cancel tests.

@jared-outpost

jared-outpost Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

on it. status:

  • Seer + Cursor findings — both flagged the same real bug (the interactive prompt captured the root-cause selection but never submitted it, then planned on a still-waiting run). fixed in 4a9c354. i checked the sentry backend for the suggested SelectRootCausePayload submission, but there's no CLI-facing endpoint that accepts a cause_id — candidate selection happens in the web UI's interactive run state. so it's now a confirm-to-continue that advances via triggerSolutionPlanning (the same step the UI fires), keeping the open-in-Sentry error for non-interactive/JSON runs. all three review threads resolved.
  • patch coverage — added tests covering the interactive confirm/decline/cancel paths, the post-planning terminal states, normalizeAgentStatus null guard, and formatSchedule edge cases. the changed lines are fully exercised; final number will show on the codecov check.

i won't merge while required checks are still running — they're pending right now. once they're green and assuming no new review comments land, i'll squash-merge per your go-ahead.

@jared-outpost
jared-outpost Bot enabled auto-merge (squash) September 28, 2026 17:04
@BYK

BYK commented Sep 28, 2026

Copy link
Copy Markdown
Member

Jared - fix lint/typecheck too (see CI failure) and we should be good

CI's biome formatter requires the multi-line signature after the export.
@vercel
vercel Bot temporarily deployed to Preview – sentry-local September 28, 2026 17:33 Inactive
@jared-outpost

jared-outpost Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

fixed in cdeb04c — the CI failure was a biome formatter rule (it wanted the normalizeAgentStatus signature wrapped across lines after adding export). my local per-file lint hadn't resolved the shared ultracite config the same way CI does, so it slipped through. ran the full biome check (the exact CI command) and tsc --noEmit locally now — both clean. auto-merge is still armed, so it'll land once the required checks go green on this commit.

@jared-outpost
jared-outpost Bot merged commit 30f92db into main Sep 28, 2026
37 checks passed
@jared-outpost
jared-outpost Bot deleted the cursor/sentry-cli-bug-fixes-4fe7 branch September 28, 2026 17:41

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — cdeb04c7 Deployed Sep 28, 2026 by vercel[bot]
Preview – sentry-local — cdeb04c7 Deployed Sep 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jared Trigger the Jared agent to work on stuff risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants