Skip to content

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

Draft
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/sentry-cli-bug-fixes-4fe7
Draft

fix: guard against null status in seer API, plan command, and monitor schedule formatting#1104
cursor[bot] wants to merge 3 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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant