Skip to content

Commit b30e7d4

Browse files
VJ-yadavVijay Yadav
authored andcommitted
fix: normalize pagination inputs to finite integers
Coerce offset/limit to finite integers via Number.isFinite and Math.trunc before using them for slice and returning in metadata. Prevents NaN, fractional, or infinite values from producing invalid display ranges. Co-Authored-By: Vijay Yadav <[email protected]>
1 parent 3528f48 commit b30e7d4

File tree

1 file changed

+4
-2
lines changed
  • packages/opencode/src/altimate/observability

1 file changed

+4
-2
lines changed

packages/opencode/src/altimate/observability/tracing.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,10 @@ export class Trace {
10141014
limit: number
10151015
}> {
10161016
const all = await Trace.listTraces(dir)
1017-
const offset = Math.max(0, options?.offset ?? 0)
1018-
const limit = Math.max(1, options?.limit ?? 20)
1017+
const rawOffset = options?.offset ?? 0
1018+
const rawLimit = options?.limit ?? 20
1019+
const offset = Number.isFinite(rawOffset) ? Math.max(0, Math.trunc(rawOffset)) : 0
1020+
const limit = Number.isFinite(rawLimit) ? Math.max(1, Math.trunc(rawLimit)) : 20
10191021
return {
10201022
traces: all.slice(offset, offset + limit),
10211023
total: all.length,

0 commit comments

Comments
 (0)