-
-
Notifications
You must be signed in to change notification settings - Fork 8
fix: consolidate Cursor BugBot PRs (#908, #947, #973, #1023, #1044) #1051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8a25d9e
d48dfec
8ed120d
66fb25f
6253ac0
48b80b6
e245a77
817389d
8865da1
5ca856b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -199,7 +199,19 @@ export type ListIssueEventsOptions = { | |
| * | ||
| * Uses the SDK's `listAnIssue_sEvents` endpoint with region-aware routing. | ||
| * When `limit` exceeds {@link API_MAX_PER_PAGE} (100), auto-paginates through | ||
| * multiple API calls to fill the requested limit, bounded by {@link MAX_PAGINATION_PAGES}. | ||
| * multiple API calls to fill the requested limit, bounded by | ||
| * {@link MAX_PAGINATION_PAGES}. | ||
| * | ||
| * Page size is capped at `min(limit, API_MAX_PER_PAGE)` via `per_page`, which | ||
| * Sentry accepts on this route at runtime even though it is absent from the | ||
| * OpenAPI spec. Capping page size keeps the server-issued `nextCursor` aligned | ||
| * to a page boundary, preventing the skip bug where trim + keep-cursor would | ||
| * jump past items. | ||
| * | ||
| * When trimming to `limit`, `nextCursor` is PRESERVED: the events cursor is | ||
| * offset-based, so resuming from it re-includes any trimmed tail rather than | ||
| * skipping it. This prevents both the original skip bug and the stall | ||
| * (drop-cursor) regression. | ||
| * | ||
| * @param orgSlug - Organization slug for region routing | ||
| * @param issueId - Numeric issue ID | ||
|
|
@@ -214,12 +226,13 @@ export async function listIssueEvents( | |
| const { limit = 25, query, full, cursor, statsPeriod, start, end } = options; | ||
|
|
||
| const config = await getOrgSdkConfig(orgSlug); | ||
| const perPage = Math.min(limit, API_MAX_PER_PAGE); | ||
|
|
||
| const allEvents: IssueEvent[] = []; | ||
| let currentCursor = cursor; | ||
| let nextCursor: string | undefined; | ||
|
|
||
| for (let page = 0; page < MAX_PAGINATION_PAGES; page++) { | ||
| for (let page = 0; page < MAX_PAGINATION_PAGES; page += 1) { | ||
| const result = await listAnIssue_sEvents({ | ||
| ...config, | ||
| path: { | ||
|
Comment on lines
228
to
238
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: When Suggested FixWhen the number of fetched items exceeds the requested Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
@@ -233,7 +246,10 @@ export async function listIssueEvents( | |
| statsPeriod, | ||
| start, | ||
| end, | ||
| }, | ||
| // `per_page` is accepted at runtime but absent from the generated query | ||
| // type, so widen via cast. | ||
| per_page: perPage, | ||
| } as Parameters<typeof listAnIssue_sEvents>[0]["query"], | ||
| }); | ||
|
|
||
| const paginated = unwrapPaginatedResult( | ||
|
|
@@ -250,12 +266,10 @@ export async function listIssueEvents( | |
| currentCursor = nextCursor; | ||
| } | ||
|
|
||
| // Trim to exact limit. Unlike listIssuesAllPages (which controls per_page), | ||
| // the issue events endpoint has no per-page parameter, so the API may return | ||
| // more items than requested. We preserve nextCursor so the command-level | ||
| // cursor stack can navigate to subsequent pages. | ||
| const trimmed = | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| allEvents.length > limit ? allEvents.slice(0, limit) : allEvents; | ||
|
|
||
| return { data: trimmed, nextCursor }; | ||
| // Trim to limit but PRESERVE nextCursor. The events cursor is offset-based, | ||
| // so resuming from it re-includes any trimmed tail rather than skipping it. | ||
| // Preserving the cursor lets `-c next` advance; dropping it would strand all | ||
| // events past the first page. | ||
| const data = allEvents.length > limit ? allEvents.slice(0, limit) : allEvents; | ||
| return { data, nextCursor }; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CATCH_RE global regex
lastIndexnot reset between files, causing missed matchesBecause
CATCH_REis a module-level/gregex andlastIndexis never reset insidecheckSilentCatch, every call after the first will start scanning from where the previous file left off, silently skipping catch blocks in all subsequent files.Evidence
CATCH_REis declared at module scope with/gflag (line 277–278), makinglastIndexstateful across calls.checkSilentCatchis called once per file inside thefor (const filePath of files)loop (line 356).CATCH_RE.lastIndex = 0before beginning itsexecloop.lastIndexstays at or near the end of that file's content length; the next file's content is a fresh string, butexecstarts atlastIndexwhich is almost certainly past the end, returningnullimmediately.checkAdHocTryPatterns(line 253 area) only because that function usesString.prototype.matchAllor a freshly constructed regex — not a shared global one.Identified by Warden find-bugs · 3PA-UHS