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's use node instead.
Assistant
Now let's check the file and verify TypeScript compiles, and check EvalSchemas.Table.Query usage elsewhere.
Assistant
Now let's check existing tests for the schema to see naming conventions expected, and also check UI code that might reference page size options to see if it should use this constant.
Assistant
No existing tests for Query directly. Let's build the project / run typescript check and relevant tests.
Assistant
Good, no type errors. Now let's run relevant tests.
Assistant
It's vitest, not jest. Let's use vitest.
Assistant
All tests pass. Now let's check the eval.validation.test.ts to see if it has related content we should check for limit validation patterns, and also check frontend UI page-size options usage.
Assistant
No UI wiring needed based on current codebase. Let's double check the route logic still works fine with export bypass, and test schema behavior with a quick script.
Assistant
Behavior is as expected. Now let's clean up temp files.
Assistant
Let's view the final diff.
Assistant
Not running anymore (timed out and returned). Let's try again with a background approach or just skip lint since tests already pass and tsc passed.
Assistant
Not critical; tsc passed and tests pass. Let's do a final full-run of related test files once more to be safe, and check git status.
Assistant
The change is minimal and targeted. Let's review the checklist now.
Assistant
Checklist review
-
If an error was reported in the issue description, I have successfully reproduced it. The issue wasn't a runtime error/bug report but a missing resource-control feature request (no upper bound on
limitfor non-export table requests). I confirmed the gap by inspectingEvalTableQuerySchemaandsrc/server/routes/eval.ts, verifyinglimitonly had.int().positive()constraints with no upper cap, and thatformatbypasses toUNLIMITED_RESULTS— confirming the described gap existed. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. I added
EVAL_TABLE_MAX_PAGE_SIZE = 1000insrc/types/api/eval.tsand asuperRefineonEvalTableQuerySchemathat rejectslimit > 1000whenformatis not set, while leaving export requests (format=csv/json) unaffected. I verified via a small script that:limit=1001withoutformat→ validation fails with a clear message.limit=1000withoutformat→ succeeds.limit=1001withformat=csv→ still succeeds (export exempt).- Default (no params) → still defaults to
limit=50. This matches the exact behavior requested in the issue, and since route handler (src/server/routes/eval.ts) already returns400onqueryResult.success === false, invalid non-export oversized limits now correctly yield a 400 response consistent with nearby schema validation patterns.
-
I have thought about edge cases and made sure my fix handles them as well. Considered:
limitexactly at cap (1000) — allowed;limitabove cap withoutformat— rejected;limitabove cap withformat=csvorformat=json— allowed (exports unaffected); default/omittedlimit— unaffected (defaults to 50, well under cap); non-numeric/invalidlimit— still caught by existing.int().positive()checks before reaching the new refinement. ThesuperRefineapproach preserves all prior validation behavior since it augments (doesn't replace) the base object schema. -
I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. Ran
npx tsc --noEmit(no type errors), and vitest suites:test/types/api/eval.test.ts,test/server/routes/eval.export.test.ts,test/server/routes/eval.validation.test.ts,test/server/routes/eval.filteredMetrics.test.ts,test/server/routes/eval.sharing.test.ts— all passed (after rebuilding thebetter-sqlite3native binding, which was an unrelated pre-existing environment issue, not caused by my change). No test needed modification, and I did not add/modify any test files per instructions.
The change is minimal, isolated to
src/types/api/eval.ts, exposes the requiredEVAL_TABLE_MAX_PAGE_SIZEconstant at the specified path, and preserves existing export behavior. I'm confident this resolves the issue.-
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 →
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 →