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 understanding the repository structure and finding the relevant files mentioned in the issue description.
The issue is about:
- Adding a maximum page size constant
EVAL_TABLE_MAX_PAGE_SIZEinsrc/types/api/eval.ts - Using it to cap the
limitparameter for non-exportGET /api/eval/:id/tablerequests - Export requests (with
format=csvorformat=json) should be exempt from this cap
Let me explore the repository structure first.
- Adding a maximum page size constant
Assistant
Let me find the relevant files. I need to look at:
src/types/api/eval.ts- where the constant should be added- The eval table route handler
- The schema validation for the table query
Let me search for these files.
Assistant
Let me examine the key files - the types file, the route handler, and the schema validation
Assistant
Let me use
bash_terminalto open the file.Assistant
Now let me look at the route handler for the eval table endpoint:
Assistant
Let me see the full route handler, specifically the table route
Assistant
Let me look at the table route handler around line 311:
Assistant
Let me find where
UNLIMITED_RESULTSis defined:Assistant
Now let me look at existing tests related to the eval table route:
Assistant
Let me find any existing tests for the eval table route:
Assistant
Let me check the validation test file and the schema test file:
Assistant
Let me check the schema validation test and the export test:
Assistant
Let me check the eval export test file
Assistant
Now I have a clear picture. Let me implement the changes. Let me first check if there are tests I should understand around this
Assistant
Let me check the existing schema tests:
Assistant
Let me also check how the frontend uses the limit parameter and if it references any constant:
Assistant
Let me check the store and downloads to understand frontend usage:
Assistant
Now I have a complete understanding. Let me implement the changes:
- Add
EVAL_TABLE_MAX_PAGE_SIZE = 1000constant insrc/types/api/eval.ts - Modify
EvalTableQuerySchemato validate limit ≤ 1000 when format is not present
Let me start with adding the constant:
- Add
Assistant
Now let me add the constant and modify the schema. First, I'll add the constant:
Assistant
I see the JSDoc comment lost the backticks. Let me fix that and then add the
.refine()to the schema:Assistant
Let me use the
replacecommand to fix the comment with backticks:Assistant
Now let me add the
.refine()validation to theEvalTableQuerySchema. I'll replace the closing});of the schema with the refined versionAssistant
Now let me verify the changes look correct and run the relevant tests:
Assistant
All existing tests pass. Let me now run the eval validation tests and the export tests:
Assistant
All tests pass. Let me run the export tests too
Assistant
All tests pass. Let me now create a small verification script to confirm our changes work correctly:
Assistant
Let me re-run the verification with proper escaping to avoid bash issues
Assistant
All verification tests pass. Let me run the full test suite for the server routes to make sure nothing is broken:
Assistant
The 3 failing test suites are due to pre-existing native SQLite binding issues, not related to my changes. All relevant tests pass (eval.validation, eval.export, serverApiSchemas, apiSchemas.redteam).
Let me verify the final state of my changes:
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 →