fix: guard against null status in seer API, plan command, and monitor schedule formatting#1104
Draft
cursor[bot] wants to merge 3 commits into
Draft
fix: guard against null status in seer API, plan command, and monitor schedule formatting#1104cursor[bot] wants to merge 3 commits into
cursor[bot] wants to merge 3 commits into
Conversation
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>
Contributor
|
Contributor
Codecov Results 📊❌ Patch coverage is 12.50%. Project has 5021 uncovered lines. Files with missing lines (3)
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 +4Generated by Codecov Action |
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.
Summary
Three independent bug fixes for crashes and logic errors found via codebase analysis and issue triage.
Fix 1:
normalizeAgentStatusTypeError on null/undefined statusRoot cause:
normalizeAgentStatus()insrc/lib/api/seer.tscallsstatus.toUpperCase()in its default branch, which throwsTypeErrorwhen the Seer API returns an autofix state with a null or missingstatusfield (e.g. a freshly created run).Reproduction: Call
sentry issue explainorsentry issue planagainst an issue where the autofix API response hasautofix.statusas null or undefined.Fix: Added a null/undefined guard that defaults to
"PROCESSING"— matching the initial state of a new autofix run.Fix 2:
plancommand proceeds to solution planning when root cause needs user input (GitHub #958)Root cause: When
ensureRootCauseAnalysisreturns withWAITING_FOR_USER_RESPONSEstatus (user needs to select a root cause in the Sentry web UI), the plan command proceeds to calltriggerSolutionPlanninganyway, 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
ensureRootCauseAnalysisthat throws a clearCliErrordirecting the user to the Sentry UI. Also added aWAITING_FOR_USER_RESPONSEcheck after solution polling to avoid the misleading "could not identify a code fix" message.Fix 3:
formatScheduleunguarded array access in monitor listRoot cause:
formatSchedule()insrc/commands/monitor/list.tsaccessesconfig.schedule[0]andconfig.schedule[1]without checking array length, producing"every undefined undefined"for empty or single-element schedule arrays.Reproduction:
sentry monitor listagainst an org with a monitor whose interval schedule array has fewer than 2 elements.Fix: Added a
schedule.length < 2guard that falls back to stringifying the first element for malformed arrays.