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 look at the relevantfile and structure.
Assistant
Let me find the route that uses this schema.
Assistant
Let me look at the tests for this area.
Assistant
Let me look at the OpenAPI spec to understand the evaltable schema better.
Assistant
Let me also check existing related tests:
Assistant
Now let me check what existing UI usage exists for page size related settings:
Assistant
Now let me look at the existing api/eval.ts file structure more carefully:
Assistant
Now let me look at what happens in the route when validation fails:
Assistant
Let me check how the schema is imported and used:
Assistant
Let me also look at how
superRefineis used in the codebase to make sure I follow the right pattern:Assistant
Let me first write a reproduction script to confirm the current behavior.
Assistant
Now let me make the changes. First, I'll modify
src/types/api/eval.tsto add the constant and update the schema:Assistant
Now let me make the changes:
Assistant
Let me check the current contents:
Assistant
Let me use replace to make the changes:
Assistant
Let me write the new content to a separate file to avoid escape issues:
Assistant
Let me verify the change:
Assistant
Now let me verify the changes work:
Assistant
All cases are working correctly:
- Without format: limit > 1000 is rejected
- With format (csv/json): any limit is accepted (including MAX_SAFE_INTEGER)
- Boundary case: limit = 1000 is accepted
- Default limit of 50 still works
Now let me verify the route still works correctly. Let me check the route handler:
Assistant
Let me also use the constant in the route for consistency:
Assistant
Now let me check how
superRefineerrors look when used withprettifyError:Assistant
The error message is well-formatted. Now let me check the existing tests to see if they still pass:
Assistant
All existing tests pass. Now let me also look at the redteam test for the schema:
Assistant
Now let me run the existing tests:
Assistant
The test failure looks unrelated to my changes - it's a database initialization issue. Let me verify by reverting and running the same test:
Assistant
Good - the failure is pre-existing. Let me restore my changes:
Assistant
Let me check whether the constant is actually used in the route, and if not, revert the import:
Assistant
Let me revert the unused import from the route:
Assistant
Let me clean up the extra blank line:
Assistant
Looks like
newis a reserved word in JS. Let me rename:Assistant
Now let me run the existing tests again to make sure everything still works:
Assistant
Now let me also test with a more end-to-end test to validate route behavior:
Assistant
All the tests pass. Now let me also test the route directly to ensure the validation properly returns 400:
Assistant
Let me try a different approach to test the route:
Assistant
The test infrastructure seems to be having issues with
beforeAll. Let me check the existing test file structure:Assistant
Let me check the existing test file imports:
Assistant
All 4 tests pass:
- Returns 400 when non-export limit exceeds max ✓
- Accepts limit at the boundary (1000) for non-export requests ✓
- Accepts large limits when format=csv is set ✓
- Accepts Number.MAX_SAFE_INTEGER when format=csv is set ✓
Let me clean up the temporary test file:
Assistant
Let me run the existing eval.export.test.ts to make sure it still passes:
Assistant
All 13 export tests pass. Let me also check the other related test files:
Assistant
All tests pass. Let me also look at the structure of the file once more to confirm everything looks good:
Assistant
Let me also verify TypeScript compilation:
Assistant
There's a TypeScript error. Let me check the Zod version:
Assistant
Let me fix the schema to use the correct property name:
Assistant
Now let me run the TypeScript check again:
Assistant
TypeScript compiles cleanly. Now let me verify the tests still pass:
Assistant
All 76 tests pass. Let me also verify the schema still works as expected:
Assistant
Excellent! Everything works correctly. Let me also make sure the diff is clean and minimal:
Assistant
Let me run the linter to make sure the code is clean:
Assistant
No linting errors. Let me also run a broader test to make sure I haven't broken anything else:
Assistant
The test failures are all due to the same pre-existing database initialization issue (
Cannot read properties of undefined (reading 'listening')), not related to my changes. Let me verify by checking what tests pass andfail:Assistant
Let me verify these failures are pre-existing by reverting my changes temporarily:
Assistant
Confirmed - these 4 test failures are pre-existing and not related to my changes. Let me restore my changes:
Assistant
Let me run all the related tests one more time to make sure everything works:
Assistant
All 76 tests pass. Let me also run a final view of the changes:
Assistant
Let me also verify the linting once more:
Assistant
Now let me also run the broader types test to make sure no types are broken:
Assistant
All 410 type tests pass. Let me do a final summary review of the 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 →