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 call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Add a maximum
Assistant
Let me start by understanding the repository structure and the issue. The issue is about capping the eval table page size for non-export requests in a Node.js/TypeScript project called "promptfoo". Let me explore the repository structure first.
The key points:
GET /api/eval/:id/tableaccepts any positive integer forlimiton normal table requests- Export requests (with
format=csvorformat=json) should remain unchanged - Need to add a maximum limit for non-export requests
- The constant should be
EVAL_TABLE_MAX_PAGE_SIZEwith value1000insrc/types/api/eval.ts - Need to update schema validation and route handling
Let me start by exploring the repository.
Assistant
Let me find the relevant files mentioned in the issue description.
Assistant
Let me look at the key files. Let's start with the types file and the route
Assistant
I need to make separate calls. Let me start with the types file.
Assistant
Now let me look at the route handler and the test files
Assistant
Let me see the full file around the table route:
Assistant
Let me look at the table route handler more closely
Assistant
Now let me look at the existing test files
Assistant
Let me check the export and validation test files
Assistant
Now let me check the validation test file:
Assistant
Now I have a good understanding. Let me also check the error helper and see what
EvalResultsFilterModeis:Assistant
Let me look at the error utility
Assistant
Now let me check what
EvalResultsFilterModeis:Assistant
Let me also check the app store for how page sizes are used in the UI:
Assistant
Let me check the store to see how pageSize is used and if there's any reference to a max page size in the UI:
Assistant
Let me check the page size selector UI to see what options are offered
Assistant
Let me look at the select options for pageSize:
Assistant
Let me see the rest of this section:
Assistant
Now I have a complete understanding. Let me implement the changes:
Plan:
- Add
EVAL_TABLE_MAX_PAGE_SIZE = 1000constant insrc/types/api/eval.ts - Update
EvalTableQuerySchemato add a.refine()that caps non-export limits (exports withformatare exempt) - The route handler already overrides limit with
UNLIMITED_RESULTSfor exports — no changes needed there
Let me start:
- Add
Assistant
Now let me add the constant and update the schema. First, let me add the constant:
Assistant
Let me check the file state:
Assistant
The constant wasn't added. Let me use replace to add it properly
Assistant
Let me search for the exact text to understand the whitespace
Assistant
Let me see the current state of the file around that area:
Assistant
Now let me add the constant before the query schema. I'll use edit with proper EOF markers:
Assistant
Now I need to add
.refine()to the schema. Let me replace the closing});ofEvalTableQuerySchema:Assistant
The schema changes look correct. Now let me verify the schema works correctly by running a quick test
Assistant
All schema tests pass. Now let me run the existing test suite to make sure nothing is broken:
Assistant
Good, type tests pass. Let me run the validation and export tests
Assistant
Let me also run the export tests
Assistant
All tests pass. Let me also run the eval table utils test and the main eval routes test:
Assistant
All tests pass. Let me run a broader test to make sure nothing else is broken
Assistant
The failures are pre-existing database setup issues in integration tests, unrelated to my changes. All relevant tests pass (eval.test.ts, eval.validation.test.ts, eval.export.test.ts, evalTableUtils.test.ts, routes-eval.test.ts).
Let me verify the route handler doesn't need changes by double-checking the export path:
Assistant
Let me use a script file instead to avoid shell escaping issues
Assistant
Let me fix the path
Assistant
Everything works correctly. Let me check TypeScript compilation to make sure there are no type errors
Assistant
TypeScript compilation passes with no errors. Let me verify the final state of the changed file
Assistant
Let me verify the constant is accessible by checking the exports at the end of the
Assistant
Let me check the git diff to confirm only intended changes were
Assistant
The diff is clean and correct. Let me clean up the temporary script:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.