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
I'll implement the eval table page-size cap by locating the route, schema, and existing pagination patterns in the codebase.
- Assistant
Implementing the constant and schema validation, then adding tests.
- Assistant
Implemented the eval table page-size cap for non-export requests.
Changes
src/types/api/eval.ts- Added
EVAL_TABLE_MAX_PAGE_SIZE = 1000 - Extended
EvalTableQuerySchemawith asuperRefinethat rejectslimit > 1000whenformatis absent - Export requests (
format=csv/format=json) are exempt, so large explicit limits still pass schema validation and the route continues to useNumber.MAX_SAFE_INTEGER
Tests
- Schema (
test/types/apiSchemas.redteam.test.ts): rejectslimit: '1001', acceptslimit: '1000', and allowsformat: 'csv', limit: '5000' - Route (
test/server/routes/eval.validation.test.ts): returns400forlimit=1001on normal table requests; export withlimit=5000is not rejected at validation
The route handler in
src/server/routes/eval.tsis unchanged — it already validates viaEvalSchemas.Table.Query.safeParseand overrideslimittoNumber.MAX_SAFE_INTEGERwhenformatis set.All 56 tests in the affected files pass.
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.