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
I'll start by exploring the repository structure to understand the codebase. Let me first check the current directory and see what's there.
- Assistant
Let me look at the eval-related API files mentioned in the issue.
- Assistant
Let me look at the key files:
src/types/api/eval.tsand the route handler for the eval table endpoint. - Assistant
Now let me look at the route handler for the eval table endpoint:
- Assistant
Let me check the eval route handler.
- Assistant
Let me search for the table endpoint handler in the eval routes:
- Assistant
Let me look at the table endpoint more closely.
- Assistant
Let me check the
UNLIMITED_RESULTSconstant and the test file: - Assistant
Now let me look at the existing test file:
- Assistant
Let me also check how other APIs bound their page sizes for reference:
- Assistant
Let me also check the blobs schema to see the max pattern:
- Assistant
Now let me check if there are frontend pagination controls that reference this limit:
- Assistant
Let me look at the SettingsPanel to understand how the page size is currently configured.
- Assistant
Now let me look at where the page size is used in the frontend eval table:
- Assistant
Let me look more carefully at the table route for any variable naming issues:
- Assistant
Now I have a clear understanding of the codebase. Let me now look at how the schema is structured and plan my approach:
- Add
EVAL_TABLE_MAX_PAGE_SIZEconstant insrc/types/api/eval.ts - Modify
EvalTableQuerySchemato enforce the max limit only whenformatis not present (using.superRefine()) - No changes needed in the route handler since it already handles export separately
Let me first verify the test suite runs:
- Add
- Assistant
Let me check if there are route-level tests for the eval table:
- Assistant
Let me check the validation tests:
- Assistant
Now let me check the export tests:
- Assistant
Let me also check for frontend code that might reference page sizes for pagination:
- Assistant
Let me check the ResultsTable to see what page size options are available:
- Assistant
Let me see what page size options are available in the dropdown:
- Assistant
Now I have a clear picture. Let me implement the changes:
- Add
EVAL_TABLE_MAX_PAGE_SIZEconstant insrc/types/api/eval.ts - Modify
EvalTableQuerySchemato validate limit against the cap whenformatis not present - Keep exports unchanged
Let me start by editing the schema file:
- Add
- Assistant
Now let me add the constant and modify the schema:
- Assistant
Let me use line ranges for the edit:
- Assistant
I need to edit lines 83-100 to add the constant and modify the schema. Let me use the edit command with line range.
- Assistant
Let me use the edit command with line range:
- Assistant
Let me use the correct syntax for the edit command:
- Assistant
Let me try with
nodeorpythoninstead. - Assistant
Let me use node to apply the patch.
- Assistant
Now let me verify the change was applied correctly:
- Assistant
Good, the change is applied. Now let me create a quick test to verify the schema behavior:
- Assistant
Let me run the existing tests to make sure things still work:
- Assistant
Let me also run the validation route tests:
- Assistant
Let me run the export tests too:
- Assistant
Let me run the other eval-related tests:
- Assistant
The filtered metrics test fails due to database issues (native binary missing) - that's not related to my changes. Let me verify which test file passed:
- Assistant
Now let me check if the route handler needs to be updated to import the new constant. Let me look at what it currently imports:
- Assistant
Let me check how
UNLIMITED_RESULTSis used and verify the route still works correctly: - Assistant
Let me run the server API schemas test:
- Assistant
All tests pass. Now let me write a quick verification script to test the schema behavior:
- Assistant
Let me fix the path:
- Assistant
All tests pass. Let me clean up the verification test file:
- Assistant
Now let me check if the frontend code needs any updates for consistency. Let me see if it imports from the types file:
- Assistant
Let me check if there are any CLI commands that might need to know about this limit:
- Assistant
Good. Now let me run all the eval-related tests to make sure everything passes:
- Assistant
All 72 tests pass across all 5 test files. Let me also make sure the TypeScript compilation works:
- Assistant
There's a TypeScript error. The
too_bigissue requires anoriginfield in the newer version of Zod. Let me check the version and fix: - Assistant
Zod v4 has a different API for
too_bigissues. Let me check what the correct properties are. - Assistant
I need to add
origin: 'int'to the issue. Let me also check whatz.ZodIssueCodelooks like in v4: - Assistant
Good. I need to add
origin: 'int'to thectx.addIssue()call. Let me fix the schema: - Assistant
Let me use node to patch the file:
- Assistant
Let me verify the TypeScript compilation now:
- Assistant
TypeScript compilation passes. Let me run the tests again to make sure everything still works:
- Assistant
All 72 tests pass. Let me run the verification script again to make sure the behavior is correct:
- Assistant
All verification tests pass. Let me clean up the test file:
- Assistant
Let me now verify the final state of the changes I've made:
- Assistant
The changes look clean and correct. Let me do a final comprehensive test run:
- Assistant
All 72 tests pass across all 5 test files. Let me also verify the TypeScript compilation one final time:
- Assistant
Let me verify the final state of the file 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.
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 →