Cap eval table page size for non-export requests Summary GET /api/eval/:id/table accepts…
- User
Cap eval table page size for non-export requests
Summary
GET /api/eval/:id/tableaccepts any positive integer forlimiton normal table requests. The route already intentionally treats export requests differently by usingNumber.MAX_SAFE_INTEGERwhenformatis set, but non-export page requests currently do not have an upper bound.Why this matters
A very large
limitcan make a normal table request ask the server to load and serialize a large amount of eval result data in one response. Other list-style APIs in the server already bound their page sizes, so the eval table endpoint should follow the same resource-control pattern.Proposed change
- Add a maximum
limitfor non-exportGET /api/eval/:id/tablerequests. - Keep
format=csv/format=jsonexports unchanged so full-table exports still work as intended. - Return validation errors for excessive non-export limits, consistent with nearby API schema validation.
A cap of
500or1000would likely cover normal UI usage while preventing accidental oversized page requests.Validation
Suggested tests:
- schema test rejects
EvalSchemas.Table.Query.safeParse({ limit: '<cap + 1>' }) - route validation test returns
400for excessive non-exportlimit - export route tests continue to use
Number.MAX_SAFE_INTEGERwhenformatis present
Interface
Type: Constant Name: EVAL_TABLE_MAX_PAGE_SIZE Path: src/types/api/eval.ts Value/Type: constant literal value 1000 (number) Description: Server-enforced upper bound for the
limitparameter on non-export eval table page requests. Exports usingformat(csv/json) are exempt from this cap; UI pagination controls derive their available page-size options from this value. - Add a maximum
- Assistant
Now let me check where the UI derives page-size options and where the table query schema is tested.
- Assistant
Now implementing. First, the schema and constant:
- Assistant
Now the UI — derive page-size options from the constant in
ResultsTable.tsx: - Assistant
Now the route validation test:
- Assistant
Now run the tests:
- Assistant
All 50 tests pass. Now check the frontend test and type-checking:
- Assistant
Both typechecks pass. Let me verify the OpenAPI generation still works with the refined schema, since
EvalSchemas.Table.Queryis registered there: - Assistant
The changed-files scripts need
origin/main, which isn't available here. Run the tools directly on the touched files: - Assistant
Formatting is clean. Re-run the tests after the formatter touched two files:
- Assistant
All green. Final diff review:
- Assistant
Done. The eval table endpoint now caps
limitat 1000 for non-export page requests, whileformat=csv/format=jsonexports remain uncapped.Changes
src/types/api/eval.ts- Added
EVAL_TABLE_MAX_PAGE_SIZE = 1000constant (exported, documented). - Added a
.refine()onEvalTableQuerySchemathat rejectslimit > 1000unlessformatis set. In Zod 4 this keeps the schema aZodObject, so the OpenAPI registration insrc/openapi/server.tsis unaffected. The route (src/server/routes/eval.ts:318) already validates viasafeParseand returns a 400 with the prettified error, so no route change was needed — exports still substituteNumber.MAX_SAFE_INTEGERafter validation.
src/app/src/pages/eval/components/ResultsTable.tsx- Page-size selector options are now derived from
PAGE_SIZE_OPTIONS = [10, 50, 100, 500, 1000].filter(size => size <= EVAL_TABLE_MAX_PAGE_SIZE), imported from@promptfoo/types/api/eval, replacing the five hardcodedSelectItems (same disabled-when-count-too-small behavior, generalized to the previous option's value).
Tests
test/types/api/eval.test.ts: schema acceptslimitat the cap, rejectscap + 1(withpath: ['limit']), and exempts bothcsvandjsonexports even atNumber.MAX_SAFE_INTEGER.test/server/routes/eval.validation.test.ts: route returns 400 forlimit=1001without reachingEval.findById; withformat=csv&limit=999999validation passes and the request proceeds to the eval lookup.
Verification
test/types/api/eval.test.ts+test/server/routes/eval.validation.test.ts: 37 passedtest/server/routes/eval.export.test.ts(existingMAX_SAFE_INTEGERexport coverage): passedtest/server/routes/serverApiSchemas.test.ts+test/openapi/serverOpenApi.test.ts(refined schema still generates OpenAPI): 29 passedResultsTable.test.tsx: 71 passednpm run tscand frontendtsc -p tsconfig.app.json: clean- Biome + Prettier run on all four changed files (the repo's
npm run l/fscripts diff againstorigin/main, which doesn't exist in this detached checkout, so I ran the tools directly)
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →