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 me first look at the overall structure.
- Assistant
Let me get a better overview of the repository structure.
- Assistant
Let me look at the src directory structure to find the relevant API and types files.
- Assistant
Let me look at the types directory to find the API types:
- Assistant
Let me look for the API types directory:
- Assistant
Let me examine the eval types file and the eval route file:
- Assistant
Now let me look at the eval route file:
- Assistant
Let me search for the table endpoint in the eval route file:
- Assistant
Let me view the table endpoint code:
- Assistant
Let me look for the UNLIMITED_RESULTS constant:
- Assistant
Now let me check if there are any tests for the eval table endpoint:
- Assistant
Let me check the existing tests to understand the structure:
- Assistant
Let me run the existing tests to make sure they pass:
- Assistant
Now I understand the issue. We need to add a maximum limit for non-export requests to the eval table endpoint. Let me create a plan:
- Define
EVAL_TABLE_MAX_PAGE_SIZEconstant insrc/types/api/eval.tswith value 1000 - Add validation in the schema to enforce this limit for non-export requests
- Run existing tests to ensure they pass
- Test our changes
Let me start by implementing the changes:
- Define
- Assistant
Now let me implement the changes. First, let me add the constant and modify the schema:
- Assistant
Let me first check the exact structure of the types file to see where to add the constant:
- Assistant
Now let me add the constant to the types file:
- Assistant
Let me use the edit command instead.
- Assistant
Now I'll add the constant after the imports and before the first schema definition. I'll use the edit command:
- Assistant
I see there's a duplicate line. Let me fix that:
- Assistant
I made a mess of the file. Let me revert it and start fresh:
- Assistant
Now let me open the file and make clean edits:
- Assistant
Now let me insert the constant properly. I'll add it after the imports:
- Assistant
Now I need to modify the EvalTableQuerySchema to add validation. Let me view the schema and add a refine:
- Assistant
Now I need to add the validation to the schema. Let me add a refine after the schema definition:
- Assistant
Good! Now let me run the existing tests to make sure they pass:
- Assistant
Now let me check if there are other tests related to the eval table endpoint:
- Assistant
Let me check the other eval test files:
- Assistant
Let me run the filtered metrics tests:
- Assistant
Let me check if there are any TypeScript compilation issues:
- Assistant
Let me run a TypeScript check on the whole project:
- Assistant
Good! The build passes. Now let me check if the constant is properly exported. Let me look at the exports:
- Assistant
Let me check if the constant is exported from the types index:
- Assistant
Let me check if the eval route file imports the constant:
- Assistant
Let me check if there are any other places where the constant might be useful, like in the frontend:
- Assistant
Let me now create a test script to verify our changes work correctly:
- Assistant
Let me run this test:
- Assistant
The test file needs to be in the test directory. Let me move it there:
- Assistant
Now let me run the test:
- Assistant
The import path is wrong. Let me fix it:
- Assistant
Now let me run the test:
- Assistant
I need to add the imports for the test framework. Let me fix this:
- Assistant
Now let me run the test:
- Assistant
Excellent! All tests pass. Now let me clean up the temporary test file since the issue says not to add tests to the repository:
- Assistant
Now let me run the existing tests again to make sure everything still works:
- Assistant
Let me also run the export tests:
- Assistant
Let me also run a TypeScript type check to make sure there are no compilation issues:
- Assistant
Good! TypeScript compilation passes. Now let me review the changes I've made:
- Assistant
Let me create a comprehensive test to verify the behavior works correctly end-to-end:
- Assistant
Let me run this verification script:
- Assistant
The path is wrong. Let me run it from the correct location:
- Assistant
Let me just run the verification with a simple Node script:
- Assistant
Let me just run it directly from the repo:
- Assistant
The issue is that the script is in /tmp but trying to import from ./src/types... relative to /tmp. Let me just put the file in the repo.
- Assistant
Let me also run a broader set of tests to make sure nothing is broken:
- Assistant
Let me also verify some edge cases:
- Assistant
Let me also check if the constant is properly exported from the types index file:
- Assistant
Let me check what's in the types index file:
- Assistant
Let me also check if there are any other places where the constant might be useful. For example, in the frontend for pagination controls:
- Assistant
Let me check if there are any other tests that might be affected by our changes:
- Assistant
Let me also run the server route smoke test:
- Assistant
Let me check how the types index file exports things:
- Assistant
Let me also run a broader set of tests to make sure nothing is broken:
- Assistant
The failure is related to database issues (better-sqlite3 bindings), not related to our changes. The validation tests all pass. Let me now also verify that the constant is properly documented in the types file:
- Assistant
Now let me verify one more time that the changes are correct by looking at the diff:
- Assistant
Now let me provide a summary of the checklist and submit the changes:
Checklist Summary:
-
If an error was reported in the issue description, I have successfully reproduced it.
- No error was reported; it's a feature request to cap the page size for non-export requests. I verified the current behavior by examining the code.
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- N/A - No error was reported.
-
I have thought about edge cases and made sure my fix handles them as well.
- Yes, I tested and verified:
- Limit exactly at EVAL_TABLE_MAX_PAGE_SIZE (1000) - accepted
- Limit exceeding EVAL_TABLE_MAX_PAGE_SIZE for non-export requests (1001) - rejected with clear error
- Yes, I tested and verified:
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.