Skip to content

Commit dbfa95f

Browse files
VJ-yadavVijay Yadav
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 <vijay@studentsucceed.com>
1 parent 219690c commit dbfa95f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • packages/opencode/src/altimate/observability

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,10 @@ export class Trace {
10021002
limit: number
10031003
}> {
10041004
const all = await Trace.listTraces(dir)
1005-
const offset = Math.max(0, options?.offset ?? 0)
1006-
const limit = Math.max(1, options?.limit ?? 20)
1005+
const rawOffset = options?.offset ?? 0
1006+
const rawLimit = options?.limit ?? 20
1007+
const offset = Number.isFinite(rawOffset) ? Math.max(0, Math.trunc(rawOffset)) : 0
1008+
const limit = Number.isFinite(rawLimit) ? Math.max(1, Math.trunc(rawLimit)) : 20
10071009
return {
10081010
traces: all.slice(offset, offset + limit),
10091011
total: all.length,

0 commit comments

Comments
 (0)