ISSUE DESCRIPTION Cap eval table page size for non-export requests Summary GET…
- User
ISSUE DESCRIPTION
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.ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Add a maximum
- Assistant
I’ll first inspect the repository structure and locate the eval API schemas, route implementation, UI pagination usage, and relevant tests. Then I’ll reproduce the current unbounded validation behavior, implement the shared constant and conditional cap, and run focused tests plus type checks where practical.
- Assistant
The current schema confirms the issue:
limitonly requires a positive integer and defaults to 50. I’ll now trace how this schema is exposed asEvalSchemas.Table.Query, inspect route middleware/order to ensure exports can remain exempt, and find UI page-size constants/options that should derive from the new public constant. - Assistant
ripgrepis unavailable in this environment, so I’ll use recursivegrepandfindto perform the same tracing. - Assistant
The shared schema is used directly by route validation and OpenAPI. A conditional object-level refinement is appropriate: reject
limit > 1000only whenformatis absent, while accepting any positive integer for CSV/JSON exports. I’ll inspect the exact route behavior and tests, plus the app’s eval table pagination controls, before editing. - Assistant
The route already converts every formatted request to
Number.MAX_SAFE_INTEGERafter schema validation, so the schema must explicitly exempt formatted queries; otherwise export requests carrying a largelimitwould regress. The eval UI has page-size options inResultsTable; I’ll inspect its imports and option generation to satisfy the interface requirement that UI choices derive from the shared constant. - Assistant
Before changing code, I’ll reproduce both key baseline behaviors directly against the schema: an unformatted
limit=1001currently succeeds, and a formatted query with that limit also succeeds. This establishes the bug while preserving the export behavior as a regression target. - Assistant
I’ll add the literal exported constant in
src/types/api/eval.ts, apply an object-level conditional refinement with an error path oflimitfor nearby validation consistency, and refactor the UI selector to generate options up to the shared cap. The generated selector retains the existing sizes and disable behavior while ensuring no offered size can exceed the server maximum. - Assistant
Python is not installed, so that edit did not apply (and the formatter confirmed no files changed). I’ll perform the same guarded replacements with a temporary inline Node script, then format and inspect the diff.
- Assistant
The diff is focused and formatted. I’ll now rerun the schema reproduction at the boundary (
1000/1001), verify both CSV and JSON remain exempt even with very large limits, and inspect the resulting validation issue path/message. - Assistant
Boundary validation now behaves correctly and the full TypeScript project check passes. Next I’ll run the focused schema and route validation suites, then locate and run export-route tests that assert the
Number.MAX_SAFE_INTEGERbehavior. - Assistant
All 59 focused schema/validation tests pass. Existing export tests explicitly cover CSV/JSON and override caller pagination with
Number.MAX_SAFE_INTEGER; I’ll run that suite and the ResultsTable UI suite to verify both the exemption and selector refactor. I’ll also make the refinement predicate explicitly boolean (format !== undefined) for clarity rather than relying on truthiness. - Assistant
The export suite passes all 13 tests, including caller-supplied pagination being replaced by
Number.MAX_SAFE_INTEGER; the ResultsTable suite passes all 71 tests (with one pre-existing React warning unrelated to this change). I’ll perform an actual HTTP request against the app to confirm an excessive unformatted limit returns 400 before model access, then review the final diff/status and run final lint checks. - Assistant
The live route returns
400with the error correctly attributed tolimit, and the final diff is clean. As a final integration check, I’ll build the app to ensure the new runtime import of the shared constant resolves and bundles correctly; afterward I’ll summarize every requested checklist item and submit. - Assistant
Implementation is complete and verified.
Checklist:
- If an error was reported, I successfully reproduced it: Yes. Before the change,
EvalSchemas.Table.Query.safeParse({ limit: '1001' })returned success, demonstrating the missing cap. - If an error was reported, I confirmed the fix resolves it: Yes. Schema boundary checks now accept
1000, reject1001, and an actualGET /api/eval/test-id/table?limit=1001returns400with the error pathlimit. - I thought about edge cases: Yes. The cap only applies when
formatis absent; both CSV and JSON accept limits throughNumber.MAX_SAFE_INTEGER. Existing positive-integer validation/defaults remain intact, and UI options are deduplicated and filtered against the shared maximum. - I ran affected existing tests and confirmed they pass: Yes. Schema/route validation: 59 passed; export route: 13 passed; ResultsTable: 71 passed. Root TypeScript checking, targeted Biome checks, diff whitespace checks, and the full app production build also pass. The UI test emitted one pre-existing React warning but had no failures.
- If an error was reported, I successfully reproduced it: Yes. Before the change,
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.