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 look at the UI pagination and existing tests.
- Assistant
The UI already caps its page-size selector at 1000, matching the proposed cap. Let me check whether the app can import from the core
src/types: - Assistant
2. Derive UI page-size options from the constant:
- Assistant
3. Add tests. First the schema test:
- Assistant
Now the route validation test:
- Assistant
Now check the export tests still hold and run everything:
- Assistant
The test asserts the error message contains the field name. Let me check:
- Assistant
The
it.eachasserts the label appears in the error message. I'll make it a dedicated test instead: - Assistant
All pass. Now check OpenAPI spec generation still works with the refined schema, plus TypeScript and the frontend:
- Assistant
Now run the remaining table-related server tests and lint/format:
- Assistant
This is the known
better-sqlite3native binding issue — per AGENTS.md, rebuild it: - Assistant
Now lint and format the changed files:
- Assistant
The changed-files scripts need
origin/mainwhich isn't available. Run the tools directly on the touched files: - Assistant
Done. The cap is implemented and verified:
Changes
src/types/api/eval.ts- Added
EVAL_TABLE_MAX_PAGE_SIZE = 1000(exported constant, per the interface spec). EvalTableQuerySchemanow has a.refine()that rejectslimit > 1000only whenformatis absent — soformat=csv/format=jsonexport requests remain exempt and the route's existingNumber.MAX_SAFE_INTEGERoverride for exports is untouched. No route change was needed: already returns 400 with the prettified Zod error on schema failure, consistent with nearby validation.
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.