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 start by exploring the repository structure to understand the codebase and locate relevant files. Let's first get an overview.
- Assistant
Let me explore the repository structure more carefully and find the relevant files mentioned in the issue.
- Assistant
Let's examine the eval types file:
- Assistant
Now let's find the route handler for the eval table endpoint:
- Assistant
Let me look at the server route for eval table.
- Assistant
Let me find the server route for eval.
- Assistant
Let me examine the server route for eval.ts to understand how the table endpoint works.
- Assistant
Let me search for the table endpoint specifically:
- Assistant
Let me look at the table endpoint implementation:
- Assistant
Now I need to find the
UNLIMITED_RESULTSconstant. Let me search for it: - Assistant
Now let's look at the existing tests:
- Assistant
Now let me check the existing test for eval table export:
- Assistant
Let me see more of this test file to understand the export format tests.
- Assistant
Now let me check if there are other APIs that have page size limits to see the pattern:
- Assistant
Let me check the configs route to see if there's a pattern for page size limits:
- Assistant
Let me look at the existing test for eval.types.ts to see if there are schema tests:
- Assistant
Let me check the validation test file:
- Assistant
Let me look more closely at the route handler to understand the flow better:
- Assistant
Now I understand the codebase. Let me implement the changes. First, I'll add the constant and update the schema:
- Assistant
I notice there's a duplicate comment. Let me fix that:
- Assistant
I see there's a duplicate comment. Let me fix that.
- Assistant
Let me use sed to remove the duplicate line instead.
- Assistant
Let me verify the changes:
- Assistant
The request was rejected because it was considered high risk
- Assistant
Let me continue with the implementation. I need to update the route handler to bypass the max limit for export requests.
- Assistant
Now I understand the issue. The current schema validation will reject requests with limit > 1000 even when format is specified. I need to update the route handler to bypass the limit validation for export requests. Let me update the route handler:
- Assistant
The edit approach is getting complicated. Let me take a simpler approach. I'll modify the route handler to override the limit before schema validation for export requests:
- Assistant
Now I understand the structure. I need to modify the route handler to handle export requests by overriding the limit before validation. Let me update the route handler:
- Assistant
Let me try with
pythoninstead. - Assistant
Let me use node to do the replacement:
- Assistant
Now let me verify the changes look correct:
- Assistant
Good, the replacement is correct. Now let me run the existing tests to make sure nothing is broken:
- Assistant
Good, the existing tests pass. Now let me run the validation tests:
- Assistant
Good, the existing tests pass. Now let me run the export tests:
- Assistant
Now let me run the main eval tests:
- Assistant
The eval.test.ts failure looks like a pre-existing database setup issue, not related to our changes. Let me run the filteredMetrics tests too:
- Assistant
These failures are pre-existing database setup issues, not related to our changes. Now let me create a test to verify that our schema changes work correctly:
- Assistant
The tests that are failing require database setup and are pre-existing failures. The tests that matter (validation, export, types) all pass.
Let me now write a quick verification script using vitest to confirm our schema works:
- Assistant
Now let me verify the full diff of all changes:
- Assistant
The changes look good. Let me run all the relevant tests one more time to make sure everything passes:
- Assistant
All 44 tests pass. Let me clean up the temporary test file and check if there are any other tests I should run:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.