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 analyze the issue. The task is to:
- Add a maximum
limitfor non-exportGET /api/eval/:id/tablerequests - Keep
format=csv/format=jsonexports unchanged - Return validation errors for excessive non-export limits
- Define a constant
EVAL_TABLE_MAX_PAGE_SIZEwith value1000insrc/types/api/eval.ts
Let me start by exploring the repository structure to understand the codebase.
- Add a maximum
Assistant
Let me start by exploring the repository structure to understand the codebase. I'll look at the source files related to eval and table APIs.
Assistant
Let me look at the types/api directory to find the eval.ts file mentioned in the issue.
Assistant
Now let me look at the server route for eval table endpoint:
Assistant
Let me see the table endpoint in the route file:
Assistant
Now let me see the specific table endpoint code around line 311:
Assistant
Now I need to find where
UNLIMITED_RESULTSis defined:Assistant
Now I understand the code structure. Let me also check the test file for this route:
Assistant
Now let me check the existing tests more thoroughly, especially related to table endpoints:
Assistant
Let me see the full test file for API schemas related to eval:
Assistant
Now let me check where the constant is referenced in other parts of the codebase:
Assistant
Let me also check how similar list endpoints cap their page sizes:
Assistant
Now I have a good understanding of the codebase. Let me look at the blobs.ts to see the pattern used there with
max(501):Assistant
Assistant
Now let me implement the changes. I'll:
- Add the
EVAL_TABLE_MAX_PAGE_SIZEconstant at the top of the file - Update the
EvalTableQuerySchemato cap the limit
- Add the
Assistant
Now I'll add the constant and update the schema. First, let me add the constant after the imports:
Assistant
Good. Now I need to update the
limitfield inEvalTableQuerySchemato use the constant. Let me find the exact line:Assistant
I see there's a double comma
,,. Let me fix that:Assistant
Now let me verify the file is valid TypeScript by checking if there are any syntax issues:
Assistant
Let me run the tests to make sure everything is working:
Assistant
All tests pass. Now let me write a quick test script to verify my changes work as expected:
Assistant
All tests pass. Now let me verify the route still works correctly for exports. The key point is that when
formatis present, the route ignores thelimitfrom the query and usesUNLIMITED_RESULTS. So exports will work fine - the client just doesn't need to pass a largelimit.Let me also verify that the constant is exported correctly by checking it can be imported:
Assistant
Good. Let me also run any related server tests to make sure nothing is broken:
Assistant
Let me also run some broader tests that might be affected:
Assistant
The test failure is due to missing
better-sqlite3native bindings, not related to my changes. Let me verify the current state of the file one more time:Assistant
The changes look good. Let me run a few more relevant tests to ensure everything is working:
Assistant
All type-related tests pass. Let me also check if there's an existing test file for the eval API types specifically:
Assistant
All tests pass. Let me clean up the temporary test script and verify the final state of my changes:
Assistant
Let me review my changes one more time:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.