Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Cap eval table page size for non-export requests Summary GET /api/eval/:id/table accepts…

  1. User

    Cap eval table page size for non-export requests

    Summary

    GET /api/eval/:id/table accepts any positive integer for limit on normal table requests. The route already intentionally treats export requests differently by using Number.MAX_SAFE_INTEGER when format is set, but non-export page requests currently do not have an upper bound.

    Why this matters

    A very large limit can 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 limit for non-export GET /api/eval/:id/table requests.
    • Keep format=csv / format=json exports 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 500 or 1000 would 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 400 for excessive non-export limit
    • export route tests continue to use Number.MAX_SAFE_INTEGER when format is 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 limit parameter on non-export eval table page requests. Exports using format (csv/json) are exempt from this cap; UI pagination controls derive their available page-size options from this value.

  2. Assistant

    Now let me check where the UI derives page-size options and where the table query schema is tested.

  3. Assistant

    Now implementing. First, the schema and constant:

  4. Assistant

    Now the UI — derive page-size options from the constant in ResultsTable.tsx:

  5. Assistant

    Now the route validation test:

  6. Assistant

    Now run the tests:

  7. Assistant

    All 50 tests pass. Now check the frontend test and type-checking:

  8. Assistant

    Both typechecks pass. Let me verify the OpenAPI generation still works with the refined schema, since EvalSchemas.Table.Query is registered there:

  9. Assistant

    The changed-files scripts need origin/main, which isn't available here. Run the tools directly on the touched files:

  10. Assistant

    Formatting is clean. Re-run the tests after the formatter touched two files:

  11. Assistant

    All green. Final diff review:

  12. Assistant

    Done. The eval table endpoint now caps limit at 1000 for non-export page requests, while format=csv/format=json exports remain uncapped.

    Changes

    src/types/api/eval.ts

    • Added EVAL_TABLE_MAX_PAGE_SIZE = 1000 constant (exported, documented).
    • Added a .refine() on EvalTableQuerySchema that rejects limit > 1000 unless format is set. In Zod 4 this keeps the schema a ZodObject, so the OpenAPI registration in src/openapi/server.ts is unaffected. The route (src/server/routes/eval.ts:318) already validates via safeParse and returns a 400 with the prettified error, so no route change was needed — exports still substitute Number.MAX_SAFE_INTEGER after validation.

    src/app/src/pages/eval/components/ResultsTable.tsx

    • Page-size selector options are now derived from PAGE_SIZE_OPTIONS = [10, 50, 100, 500, 1000].filter(size => size <= EVAL_TABLE_MAX_PAGE_SIZE), imported from @promptfoo/types/api/eval, replacing the five hardcoded SelectItems (same disabled-when-count-too-small behavior, generalized to the previous option's value).

    Tests

    • test/types/api/eval.test.ts: schema accepts limit at the cap, rejects cap + 1 (with path: ['limit']), and exempts both csv and json exports even at Number.MAX_SAFE_INTEGER.
    • test/server/routes/eval.validation.test.ts: route returns 400 for limit=1001 without reaching Eval.findById; with format=csv&limit=999999 validation passes and the request proceeds to the eval lookup.

    Verification

    • test/types/api/eval.test.ts + test/server/routes/eval.validation.test.ts: 37 passed
    • test/server/routes/eval.export.test.ts (existing MAX_SAFE_INTEGER export coverage): passed
    • test/server/routes/serverApiSchemas.test.ts + test/openapi/serverOpenApi.test.ts (refined schema still generates OpenAPI): 29 passed
    • ResultsTable.test.tsx: 71 passed
    • npm run tsc and frontend tsc -p tsconfig.app.json: clean
    • Biome + Prettier run on all four changed files (the repo's npm run l/f scripts diff against origin/main, which doesn't exist in this detached checkout, so I ran the tools directly)

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.