Skip to content

Commit 547b5be

Browse files
authored
fix(history): reject fractional page sizes (#55)
1 parent 5f7dba1 commit 547b5be

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
@@ -535,6 +535,32 @@ describe('runResultHistory — pagination', () => {
535535

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

540566
// ---------------------------------------------------------------------------

src/commands/test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3836,7 +3836,10 @@ export async function runResultHistory(
38363836
// configured (codex round-2), matching validatePaginationFlags ordering
38373837
// in `test list` / `project list`.
38383838
if (opts.pageSize !== undefined) {
3839-
if (!Number.isFinite(opts.pageSize) || opts.pageSize < 1 || opts.pageSize > 100) {
3839+
if (!Number.isFinite(opts.pageSize) || !Number.isInteger(opts.pageSize)) {
3840+
throw localValidationError('page-size', 'must be an integer between 1 and 100');
3841+
}
3842+
if (opts.pageSize < 1 || opts.pageSize > 100) {
38403843
throw localValidationError('page-size', 'must be between 1 and 100');
38413844
}
38423845
}

0 commit comments

Comments
 (0)