Skip to content

fix: 2 bug fixes — subcommand crash, negative span depth, pagination JSON parse#607

Merged
BYK merged 5 commits intomainfrom
cursor/sentry-cli-bug-fixes-7de9
Mar 30, 2026
Merged

fix: 2 bug fixes — subcommand crash, negative span depth, pagination JSON parse#607
BYK merged 5 commits intomainfrom
cursor/sentry-cli-bug-fixes-7de9

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor bot commented Mar 30, 2026

Two independent bug fixes, each in its own commit.


Fix 1: parseSpanDepth() accepts negative numbers

File: src/lib/arg-parsing.ts

Root cause: parseSpanDepth() validates NaN and keyword strings but passes negative numbers through. --spans -5 returns -5, which silently skips the span tree (the downstream spans > 0 check evaluates to false) with no feedback.

Reproduction: sentry event view <org>/<project>/<id> --spans -5 → no span tree shown, no error.

Fix: Treat negative values like invalid input: fall back to the default depth (3).


Fix 2: getPaginationState() crashes on corrupted JSON

File: src/lib/db/pagination.ts

Root cause: JSON.parse(row.cursor_stack) has no error handling. Corrupted JSON (interrupted write, manual edit, storage bug) throws an unhandled SyntaxError that crashes the command.

Reproduction: Manually corrupt the cursor_stack column in the SQLite pagination table, then run any list command with --cursor next.

Fix: Wrap JSON.parse in a try-catch. On failure, delete the corrupt row and return undefined — same behavior as an expired cursor, causing a fresh pagination start.

Open in Web View Automation 

cursoragent and others added 3 commits March 30, 2026 12:45
…ception

getSubcommandsForRoute() uses require('../app.js') which transitively
loads api-schema.ts, importing from a generated file that may not exist
during development or in CI environments without a prior build step.

Previously this threw an uncaught ResolveMessage error, crashing the
entire command. Now it catches the error and returns an empty set,
allowing the command to proceed without subcommand interception.

The catch does not cache the failure — subsequent calls will retry
loading the route tree, so the function self-heals once the generated
file becomes available.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
parseSpanDepth() accepted negative numbers like -5 or -100 and returned
them as-is. Negative depth values are nonsensical for span tree display
and cause the span tree to be silently skipped (since the downstream
`spans > 0` check evaluates to false) without any feedback to the user.

Now treats negative values the same as non-numeric input: falls back to
the default depth (3).

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
getPaginationState() calls JSON.parse(row.cursor_stack) without error
handling. If the stored JSON is corrupted (e.g., from an interrupted
write, manual DB edit, or storage bug), this throws an unhandled
SyntaxError that crashes the command.

Now wraps the parse in a try-catch. On failure, deletes the corrupt row
and returns undefined (treating it as missing state), which causes the
command to start fresh pagination — the same behavior as an expired
cursor.

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

github-actions bot commented Mar 30, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (upgrade) Show changelog summary during CLI upgrade by BYK in #594

Bug Fixes 🐛

  • (dashboard) Reject MRI queries with actionable tracemetrics guidance by BYK in #601
  • (skill) Avoid unnecessary auth, reinforce auto-detection, fix field examples by BYK in #599
  • (upgrade) Indent changelog, add emoji to heading, hide empty sections by BYK in #604
  • 2 bug fixes — subcommand crash, negative span depth, pagination JSON parse by cursor[bot] in #607

Internal Changes 🔧

  • Regenerate skill files and command docs by github-actions[bot] in 664362ca

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Codecov Results 📊

129 passed | Total: 129 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 55.56%. Project has 1273 uncovered lines.
❌ Project coverage is 95.74%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/lib/db/pagination.ts 50.00% ⚠️ 4 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    95.75%    95.74%    -0.01%
==========================================
  Files          203       203         —
  Lines        29851     29858        +7
  Branches         0         0         —
==========================================
+ Hits         28582     28585        +3
- Misses        1269      1273        +4
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK marked this pull request as ready for review March 30, 2026 13:24
@BYK
Copy link
Copy Markdown
Member

BYK commented Mar 30, 2026

@cursoragent revert the fix fox the first item: "getSubcommandsForRoute() crashes when generated files are missing" -- this is intentional

@cursor
Copy link
Copy Markdown
Contributor Author

cursor bot commented Mar 30, 2026

I've successfully reverted the first fix. The try-catch wrapper in getSubcommandsForRoute() has been removed, restoring the original behavior where missing generated files will cause an intentional crash.

Changes made:

  • Removed the try-catch block from getSubcommandsForRoute() in src/lib/list-command.ts
  • Committed with message: "revert: remove try-catch from getSubcommandsForRoute (crash is intentional)"
  • Pushed to branch cursor/sentry-cli-bug-fixes-7de9

The PR now contains only 2 bug fixes (negative span depth and pagination JSON parse). The PR title and description couldn't be auto-updated since they're not agent-managed, but you can manually update them if needed.

Open in Web Open in Cursor 

…ional)

Co-authored-by: Burak Yigit Kaya <BYK@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

@cursor cursor bot left a comment

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.

@BYK
Copy link
Copy Markdown
Member

BYK commented Mar 30, 2026

@cursoragent address the review comments

@cursor
Copy link
Copy Markdown
Contributor Author

cursor bot commented Mar 30, 2026

Perfect! I've addressed the review comment by fully reverting the first fix. The code is now back to its original form where:

  1. _subcommandsByRoute = new Map() is assigned eagerly at the start (not using a local map variable)
  2. The code directly calls _subcommandsByRoute.set() instead of map.set()
  3. No try-catch wrapper - the crash when generated files are missing is intentional

Changes committed:

  • First commit removed the try-catch wrapper
  • Second commit restored the original eager Map assignment pattern
  • Both commits pushed to cursor/sentry-cli-bug-fixes-7de9

The PR now contains only the 2 remaining bug fixes (negative span depth and pagination JSON parse).

Open in Web Open in Cursor 

Co-authored-by: Burak Yigit Kaya <BYK@users.noreply.github.com>
@BYK BYK changed the title fix: 3 bug fixes — subcommand crash, negative span depth, pagination JSON parse fix: 2 bug fixes — subcommand crash, negative span depth, pagination JSON parse Mar 30, 2026
@BYK BYK merged commit dc3ea98 into main Mar 30, 2026
25 checks passed
@BYK BYK deleted the cursor/sentry-cli-bug-fixes-7de9 branch March 30, 2026 15:09
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.

2 participants