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
Good, exports don't pass
limitat all. So the schema can enforce max onlimitfield itself using.max(), and whenformatis provided but no limit param, default 50 (or omitted) would apply fine but then overridden by UNLIMITED_RESULTS in route code anyway. Let's implement schema with refine or superRefine to allow limit unrestricted when format present, but simplest: use.max(EVAL_TABLE_MAX_PAGE_SIZE)unconditionally but since limit isn't sent for export requests, this is safe. Let's check test expectations to be sure.Assistant
Now let's implement the constant and update schema.
Assistant
That's just an identity function with typing, should be fine with a ZodEffects. Let's check the
RouteRequest['query']type constraint and run typecheck/build to see if things compile.Assistant
This should work fine since it's a generic ZodType constraint. Let's check
RouteRequest['query']type definition just in case, then run TypeScript compile check.Assistant
That's from a third-party library type, likely
AnyZodObjector similar. Let's just try compiling.Assistant
No errors. Now update the route to use the new constant, and check evalTableUtils.ts as well.
Assistant
No existing UI page-size selector for the table endpoint, so nothing more to change on the frontend. Now let's run existing tests to verify.
Assistant
It uses vitest, not jest. Let's use vitest.
Assistant
Now let's run full test file plus route tests for eval.
Assistant
Let's run this test file and the export test to be sure everything is fine.
Assistant
All passing. Now let's write a quick temporary script to verify the new cap behavior manually, then remove it.
Assistant
All the behaviors work as expected. Now let's check the openapi generation still works (since schema changed to ZodEffects with refine, might affect openapi doc generation).
Assistant
Passes. Now let's also check
evalTableUtils.tsaround UNLIMITED_RESULTS to ensure consistency (not required to change but let's inspect).Assistant
This is the CSV generation helper used for exports, unrelated to non-export path — fine as is. Let's also check the JSON export path in the route to ensure it's unaffected (search for
format === 'json').Assistant
This confirms the JSON export path uses
format === 'json'and getslimit = UNLIMITED_RESULTSunaffected by our schema change since format is set, bypassing the refine check. Now let's run the full eval-related test suite broadly to be safe.Assistant
Confirmed pre-existing environment issue (missing native sqlite bindings), unrelated to our change. Let's try to rebuild better-sqlite3 to see if we can get this test working too, just for thoroughness.
Assistant
Now that's fixed too. Let's re-run the full batch to confirm everything passes.
Assistant
All 97 tests pass. Let's also check the diff and TypeScript compile once more.
Assistant
No TS errors. Now let's also check
EvalSchemas.Table.Queryusage anywhere else that may rely on.shape(ZodObject specific method) which ZodEffects doesn't have.Assistant
Good, only
.safeParse/.parseused - fully compatible with.refine(). All good.Assistant
Now let's run broader test suite for the types/api folder and server routes to be thorough, and lint check.
Assistant
This is unrelated to our change (uses
Table.Response, notTable.Query). All tests pass. Let's view the final diff summary.Assistant
The change is now complete. Let me review the checklist:
Assistant
Confirmed the pre-fix behavior allowed unbounded limits, and post-fix it's capped. Let's do a final sanity re-run of the whole suite scope one more time to be safe.
Assistant
All 795 tests pass. Now let me review the checklist items explicitly.
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it. — The issue wasn't a crash/error but a missing validation constraint (unbounded
limit). I reproduced the "before" state by stashing my changes and confirming thatEvalSchemas.Table.Query.safeParse({ limit: '1000000' })succeeded with no cap, proving the reported gap existed. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. — After applying the fix, I confirmed
limit=1001(no format) is now rejected,limit=1000(no format) is accepted, and with is still accepted (exports unaffected), matching the issue's requirements exactly.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.