fix: 3 bug fixes — test env isolation, event pagination, pagination crash guard#947
Draft
cursor[bot] wants to merge 3 commits intomainfrom
Draft
fix: 3 bug fixes — test env isolation, event pagination, pagination crash guard#947cursor[bot] wants to merge 3 commits intomainfrom
cursor[bot] wants to merge 3 commits intomainfrom
Conversation
The withTTY helper only saved/restored SENTRY_PLAIN_OUTPUT and isTTY, but did not clear NO_COLOR or FORCE_COLOR. In environments where NO_COLOR is set (e.g., CI), isPlainOutput() returns true before reaching the TTY check, causing terminalLink to return plain text and two tests to fail. Save/restore NO_COLOR and FORCE_COLOR alongside SENTRY_PLAIN_OUTPUT so the tests exercise the actual OSC 8 code path regardless of the outer environment. Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
When auto-paginating issue events and the accumulated results exceed the requested limit, the function trimmed the array but preserved nextCursor. That cursor points to the next API page, skipping the untrimmed tail of the current batch — causing events to be lost during cursor-based pagination. Drop nextCursor when trimming, matching the existing behavior of listIssuesAllPages in issues.ts which correctly returns no cursor when results are trimmed. Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
getPaginationState() calls JSON.parse on cursor_stack from SQLite without a try/catch. If the stored JSON is corrupt (partial write, manual edit, incompatible migration), the CLI crashes with an unhandled SyntaxError instead of degrading gracefully. Wrap JSON.parse in try/catch. On parse failure, log a debug message, delete the corrupt row, and return undefined (treating it as no saved state). This lets the user continue navigating from a fresh first page rather than being stuck with a hard crash. Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
Contributor
Codecov Results 📊✅ 6856 passed | Total: 6856 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ❌ Patch coverage is 35.29%. Project has 14050 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 76.97% 76.97% —%
==========================================
Files 319 319 —
Lines 60994 61003 +9
Branches 0 0 —
==========================================
+ Hits 46947 46953 +6
- Misses 14047 14050 +3
- Partials 0 0 —Generated 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 discovered through codebase analysis and test failure investigation.
1. fix(test): complete env isolation in terminalLink tests
Root cause: The
withTTYhelper incolors.test.tsonly saved/restoredSENTRY_PLAIN_OUTPUTandprocess.stdout.isTTY, but did not clearNO_COLORorFORCE_COLOR. In CI environments (or any shell withNO_COLORset),isPlainOutput()returnstrueat theNO_COLORcheck before reaching the TTY fallback, causingterminalLinkto return plain text.Reproduction: Run
NO_COLOR=1 bun test ./test/lib/formatters/colors.test.ts— twoterminalLinkTTY tests fail.Fix: Save/restore
NO_COLORandFORCE_COLORalongsideSENTRY_PLAIN_OUTPUTin thewithTTYhelper.2. fix(events): drop nextCursor when trimming listIssueEvents results
Root cause:
listIssueEvents()auto-paginates through the API and trims results tolimit. When trimming, it preservednextCursor— but that cursor points to the next API page, skipping the un-trimmed tail of the current batch. This causes events to be lost during cursor-based pagination.Reproduction: Call
listIssueEventswith alimitsmaller than the API page size for an issue with many events — subsequent-c nextnavigation skips events between the trim point and the next API page boundary.Fix: Drop
nextCursorwhen trimming, matching the existing correct behavior oflistIssuesAllPagesinissues.ts(lines 253-257).3. fix(pagination): guard JSON.parse of cursor_stack against corrupt data
Root cause:
getPaginationState()callsJSON.parse(row.cursor_stack)on data read from SQLite without a try/catch. If the stored JSON is corrupt (partial write, manual edit, incompatible migration), the CLI crashes with an unhandledSyntaxError.Reproduction: Manually corrupt the
cursor_stackcolumn in thepagination_cursorstable, then run any command with--cursor next.Fix: Wrap
JSON.parsein try/catch. On failure, log a debug message, delete the corrupt row, and returnundefined— the user continues from a fresh first page instead of a hard crash.