Skip to content

Commit ebfb5a4

Browse files
committed
fix(history): reject fractional page sizes
1 parent 15e95de commit ebfb5a4

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/commands/test.result.history.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,32 @@ describe('runResultHistory — pagination', () => {
533533

534534
expect(capturedUrl).toContain('pageSize=5');
535535
});
536+
537+
it('rejects fractional --page-size before making a request', async () => {
538+
const { credentialsPath } = makeCreds();
539+
const fetchImpl = makeFetch(() => {
540+
throw new Error('should not be called');
541+
});
542+
543+
await expect(
544+
runResultHistory(
545+
{
546+
output: 'json',
547+
testId: 'test_abc',
548+
pageSize: 1.5,
549+
profile: 'default',
550+
dryRun: false,
551+
debug: false,
552+
verbose: false,
553+
},
554+
{ credentialsPath, fetchImpl, stdout: () => {} },
555+
),
556+
).rejects.toMatchObject({
557+
code: 'VALIDATION_ERROR',
558+
exitCode: 5,
559+
details: expect.objectContaining({ field: 'page-size' }),
560+
});
561+
});
536562
});
537563

538564
// ---------------------------------------------------------------------------

src/commands/test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3799,7 +3799,10 @@ export async function runResultHistory(
37993799
// configured (codex round-2), matching validatePaginationFlags ordering
38003800
// in `test list` / `project list`.
38013801
if (opts.pageSize !== undefined) {
3802-
if (!Number.isFinite(opts.pageSize) || opts.pageSize < 1 || opts.pageSize > 100) {
3802+
if (!Number.isFinite(opts.pageSize) || !Number.isInteger(opts.pageSize)) {
3803+
throw localValidationError('page-size', 'must be an integer between 1 and 100');
3804+
}
3805+
if (opts.pageSize < 1 || opts.pageSize > 100) {
38033806
throw localValidationError('page-size', 'must be between 1 and 100');
38043807
}
38053808
}

0 commit comments

Comments
 (0)