diff --git a/src/commands/dashboard/revisions.ts b/src/commands/dashboard/revisions.ts index 874ba27ba..bc06c020a 100644 --- a/src/commands/dashboard/revisions.ts +++ b/src/commands/dashboard/revisions.ts @@ -199,8 +199,12 @@ export const revisionsCommand = buildCommand({ ); const trimmed = results.slice(0, flags.limit); - const hasMore = results.length > flags.limit || !!nextCursor; - const cursorToStore = hasMore ? nextCursor : undefined; + const overshot = results.length > flags.limit; + const hasMore = overshot || !!nextCursor; + // When multi-page fetch overshoots the limit, the API cursor points past + // trimmed items — storing it would skip them on '-c next'. Drop it to + // match autoPaginate() behavior (see infrastructure.ts lines 419-420). + const cursorToStore = !overshot && hasMore ? nextCursor : undefined; advancePaginationState( PAGINATION_KEY, diff --git a/src/lib/api/logs.ts b/src/lib/api/logs.ts index d128091f2..f01c8ecd8 100644 --- a/src/lib/api/logs.ts +++ b/src/lib/api/logs.ts @@ -161,7 +161,7 @@ export async function listLogs( field: fields, project: isNumericProject ? [Number(projectSlug)] : undefined, query: fullQuery || undefined, - per_page: options.limit || API_MAX_PER_PAGE, + per_page: Math.min(options.limit || API_MAX_PER_PAGE, API_MAX_PER_PAGE), statsPeriod: options.start || options.end ? undefined @@ -343,7 +343,7 @@ export async function listTraceLogs( : (options.statsPeriod ?? "14d"), start: options.start, end: options.end, - per_page: options.limit ?? API_MAX_PER_PAGE, + per_page: Math.min(options.limit ?? API_MAX_PER_PAGE, API_MAX_PER_PAGE), query: options.query, sort: toApiSort(options.sort), }, diff --git a/src/lib/sourcemap/debug-id.ts b/src/lib/sourcemap/debug-id.ts index 25608c2df..62f838fcf 100644 --- a/src/lib/sourcemap/debug-id.ts +++ b/src/lib/sourcemap/debug-id.ts @@ -13,6 +13,7 @@ import { createHash } from "node:crypto"; import { readFile, writeFile } from "node:fs/promises"; +import { ValidationError } from "../errors.js"; import { logger } from "../logger.js"; import { type DecodedInlineMap, @@ -152,7 +153,16 @@ export async function injectDebugId( newJs += `\n${DEBUGID_COMMENT_PREFIX}${debugId}\n`; // --- Mutate sourcemap --- - const map = JSON.parse(mapContent) as SourcemapJson; + let map: SourcemapJson; + try { + map = JSON.parse(mapContent) as SourcemapJson; + } catch (error) { + log.debug("Failed to parse sourcemap JSON", error); + throw new ValidationError( + `Failed to parse sourcemap ${mapPath}: file is not valid JSON`, + "mapPath" + ); + } mutateSourcemap(map, debugId, { offsetMappings: !skipSnippet }); // Write both files concurrently