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 first locate the eval API schemas, route implementation, UI pagination usage, and relevant tests/package scripts. Then I’ll reproduce the current unbounded validation, implement the shared constant and conditional cap, and run focused tests plus type checks if available.
- Assistant
The schema currently applies only positivity, confirming the reported gap. Because exports must bypass the cap while the same query schema validates both modes, a simple
.max(1000)onlimitwould incorrectly reject exports; I’ll inspect the route’s parsing flow and schema namespace/export patterns to choose an object-level conditional validation that preserves coercion and defaults. - Assistant
The issue’s interface description also requires UI pagination options to derive from the new constant, so I’ll inspect the existing option list and app import conventions rather than only changing server validation. I’ll also examine route tests to ensure conditional behavior is tested at the correct boundary without altering tests.
- Assistant
A schema-level
.superRefineis appropriate: after Zod coerces query strings, reject only whenformatis absent andlimit > 1000, with the issue path set tolimitso route errors remain consistent. Export requests can still supply any positive integer, and the route will continue replacing it withNumber.MAX_SAFE_INTEGER. I’ll verify whether frontend code may import the API type module directly and inspect the remainder of the selector before editing. - Assistant
Before changing code, I’ll run a minimal schema parse to record the reproduction: a non-export
limit=1001should currently succeed. Then I’ll add the exported literal constant, conditional refinement, and a generated UI option list whose maximum comes from that same constant. - Assistant
The first reproduction command hit shell history expansion on
!; I’ll rerun it using a positive condition so the result reflects schema behavior rather than shell parsing. - Assistant
The reproduction confirms
1001is accepted. I’ll now make the schema cap conditional on the parsedformat, preserving export limits and all existing defaults/coercions. In the UI, I’ll centralize the options and render them from an array ending in the shared cap, retaining the existing disabled behavior based on the preceding option. - Assistant
Python is unavailable in this environment, so no files were changed. I’ll apply the same targeted transformations with Node (already provided by the repository), then run Biome and inspect the diff.
- Assistant
The server schema edit applied and formatted, while the frontend script intentionally aborted before writing because its insertion marker did not match the actual declaration name. I’ll locate the first post-import declaration and then apply only the frontend change, avoiding any duplicate server edits.
- Assistant
I found the module constants section. I’ll add the page-size list there and replace the static selector items, then format and inspect both files.
- Assistant
The diff now matches the intended behavior. I’ll verify edge cases directly at the schema boundary: the cap itself must pass, cap+1 must fail for normal requests with a
limit-path issue, and both CSV/JSON requests withNumber.MAX_SAFE_INTEGERmust pass. Then I’ll run focused schema, route-validation, export, and UI tests. - Assistant
All focused tests pass (44 server/schema/export tests and 71 ResultsTable tests), and direct checks confirm export exemption. I’ll now run TypeScript checking and OpenAPI tests because the shared runtime import and refined schema can affect those build surfaces. I’ll also inspect the final status for accidental files.
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 →