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 callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /promptfoo, current file: none) bash-$
- Add a maximum
Assistant
Let me start by exploring the repository structure to understand the codebase.
Assistant
Let me explore the relevant directory and find the eval table route.
Assistant
Now let me look at the types/api/eval.ts file to understand the schema:
Assistant
Now let me look at the existing tests for the eval table route:
Assistant
Let me check similar list-style APIs to see the pattern used for cap page sizes:
Assistant
Let me check if there are tests for the schema validation:
Assistant
Now let me check the entire test/types/apiSchemas.redteam.test.ts file to understand the test structure:
Assistant
Now let me look at the frontend code that uses the limit:
Assistant
Let me look at the export route tests more carefully:
Assistant
Let me look at the route validation logic in detail:
Assistant
Now let me check the current state of
src/server/routes/eval.tsto understand the full route flow:Assistant
Let me also see how
paramsandqueryare validated to understand the structure:Assistant
Let me see if there are any other places that use thisendpoint:
Assistant
Let me look at all the tests that use limit with format:
Assistant
Let me look at how other schemas in the codebase handle conditional validation:
Assistant
Now let me check if there are other places that use the limit/eval table schema:
Assistant
Let me also check the existing structure of the eval.ts file in src/types/api/:
Assistant
Now I have a good understanding of the codebase. Let me write a quick reproduction script to confirm the issue:
Assistant
Now I have confirmed the issue. Let me implement the fix:
Assistant
Now I'll make the changes to add the constant and the conditional validation:
Assistant
Let me make the change to the eval.ts file. I'll add the constant and modify the schema to apply the cap only when format is not set.
Assistant
Now let me run the reproduction script to confirm the fix works:
Assistant
All tests pass as expected. Now let me run the existing tests to make sure nothing is broken:
Assistant
This is a pre-existing issue with the better-sqlite3 native bindings - not related to my change. Let me verify this:
Assistant
Confirmed - this is a pre-existing issue. Let me restore my changes:
Assistant
Now let me run all the related tests to make sure everything still works:
Assistant
Let me try to rebuild better-sqlite3 to make these tests pass:
Assistant
All 107 tests pass! Let me also run a broader set of tests:
Assistant
All 906 tests pass. Let me also verify the change in OpenAPI generation still works:
Assistant
Let me clean up the temp file I created:
Assistant
Now let me also check the diff to make sure my changes are clean:
Assistant
Let me check the error message convention used by Zod's built-in
.max()validator to ensure consistency:Assistant
Let me update the error message to match Zod's standard format for consistency:
Assistant
Let me verify the change by running my reproduction script again:
Assistant
Now let me re-run all the tests to ensure nothing is broken:
Assistant
All 906 tests pass. Let me clean up:
Assistant
Let me do a final review of the changes:
Assistant
Let me do a final verification by running all the related tests:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →