fix: 2 bug fixes — subcommand crash, negative span depth, pagination JSON parse#607
fix: 2 bug fixes — subcommand crash, negative span depth, pagination JSON parse#607
Conversation
…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>
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ 129 passed | Total: 129 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ❌ Patch coverage is 55.56%. Project has 1273 uncovered lines. Files with missing lines (1)
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 |
|
@cursoragent revert the fix fox the first item: "getSubcommandsForRoute() crashes when generated files are missing" -- this is intentional |
|
I've successfully reverted the first fix. The try-catch wrapper in Changes made:
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. |
…ional) Co-authored-by: Burak Yigit Kaya <BYK@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
|
@cursoragent address the review comments |
|
Perfect! I've addressed the review comment by fully reverting the first fix. The code is now back to its original form where:
Changes committed:
The PR now contains only the 2 remaining bug fixes (negative span depth and pagination JSON parse). |
Co-authored-by: Burak Yigit Kaya <BYK@users.noreply.github.com>



Two independent bug fixes, each in its own commit.
Fix 1:
parseSpanDepth()accepts negative numbersFile:
src/lib/arg-parsing.tsRoot cause:
parseSpanDepth()validates NaN and keyword strings but passes negative numbers through.--spans -5returns -5, which silently skips the span tree (the downstreamspans > 0check 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 JSONFile:
src/lib/db/pagination.tsRoot cause:
JSON.parse(row.cursor_stack)has no error handling. Corrupted JSON (interrupted write, manual edit, storage bug) throws an unhandledSyntaxErrorthat crashes the command.Reproduction: Manually corrupt the
cursor_stackcolumn in the SQLite pagination table, then run any list command with--cursor next.Fix: Wrap
JSON.parsein a try-catch. On failure, delete the corrupt row and returnundefined— same behavior as an expired cursor, causing a fresh pagination start.