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
Let me explore the repository structure and find the relevant files.
Assistant
Let me look at the files one at a time.
Assistant
Now let me find the route handler for the eval table endpoint.
Assistant
Let me look at the route handler in detail.
Assistant
Now I understand the structure. I need to:
- Add the
EVAL_TABLE_MAX_PAGE_SIZEconstant tosrc/types/api/eval.ts. - Update the
EvalTableQuerySchemaso that the limit has a max for non-export requests.
The schema uses
prefault(50)andz.coerce.number().int().positive(). But the cap only applies to non-export requests. The schema itself doesn't know about the format. So I need to use arefineorsuperRefineto check that ifformatis not set, thenlimit <= EVAL_TABLE_MAX_PAGE_SIZE.Let me look at how the schema is currently structured. The
EvalTableQuerySchemais a flat object withformatandlimit. I can add a.superRefinethat checks the relationship.Let me write the schema with superRefine. Let me check what z version is used and whether
z.prettifyErrorexists.- Add the
Assistant
Let me check existing tests for the eval table schema and route.
Assistant
Now let me look at the export test to ensure I don't break those.
Assistant
These export tests are mostly simulated manually (not actually going through the route), so the schema validation doesn't apply there. They use
Number.MAX_SAFE_INTEGERdirectly in the simulated code.Now, let me implement the changes. I'll:
- Add
EVAL_TABLE_MAX_PAGE_SIZEconstant tosrc/types/api/eval.ts. - Update
EvalTableQuerySchemato enforce the cap for non-export requests using asuperRefine.
- Add
Assistant
Now let me edit the schema to add the constant and the cap validation.
Assistant
Let me check the frontend where the table is requested, to see if the constant should be used there too.
Assistant
Let me search for page size options in the UI.
Assistant
Let me look at the page size options used in the UI table.
Assistant
The UI page-size options may include values that could exceed 1000. Let me check the page size select options.
Assistant
The page size options max out at 1000, matching our cap. Now let me write a quick reproduction/verification script and run existing tests.
Assistant
Let me run the existing schema test first to make sure my change compiles and passes.
Assistant
Now let me write a temporary verification test to confirm the schema behavior.
Assistant
All checks pass. Now let me run the route validation test and export tests to ensure nothing breaks.
Assistant
The filteredMetrics test failure is a pre-existing database/migration environment issue unrelated to my change (it fails at
runDbMigrations/getDbbefore any schema logic). Let me confirm it fails on the clean tree too.Assistant
Confirmed - the filteredMetrics test failure is pre-existing and unrelated to my change. Now let me remove the temporary test file and verify the final diff.
Assistant
The route already uses
EvalSchemas.Table.Query.safeParseand returns 400 withz.prettifyError, so no route changes are needed — the schema now automatically rejects excessive non-export limits. Let me run the validation test once more to confirm the existinglimitcases still work.Assistant
All validation tests pass. Let me also run the schema test and downloads test.
Assistant
The downloads test didn't run (wrong path). Let me check.
Assistant
The
downloads.test.tsis run via a separate frontend vitest config, not relevant to my change. My fix is complete and verified.Let me do a final review of 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.