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
I’ll inspect the repository structure and locate the eval API schema and table route, then trace how
limitis validated and applied. I’ll implement the exportedEVAL_TABLE_MAX_PAGE_SIZE = 1000constant, wire it into non-export validation while preserving export behavior, run focused tests (and broader relevant tests if practical), and review the final diff. - Assistant
The repository is a TypeScript project with dependencies already installed. The initial broad search did not show the exact symbols, so I’ll enumerate the API/type files and search specifically under
srcandtestfor the eval route and schema definitions. - Assistant
rgis unavailable in this shell despite the earlier command being partially successful, so I’ll usegrep. The relevant files aresrc/types/api/eval.tsandsrc/server/routes/eval.ts; I’ll inspect those plus nearby tests and package scripts to understand the project’s validation conventions. - Assistant
The current query schema only requires a positive integer, confirming the reported gap. I’ll now inspect the route’s validation wrapper and the
EvalSchemasexport, because the requested cap must be visible throughEvalSchemas.Table.Queryand exports must remain exempt by selectingNumber.MAX_SAFE_INTEGERafter parsing. - Assistant
The route already correctly switches to
Number.MAX_SAFE_INTEGERwheneverformatis present, so the cleanest fix is a schema-level conditional refinement: caplimitonly whenformatis absent. This makes excessive normal requests fail with the existing 400 path, while allowing export queries to retain their existing semantics. I’ll also check whether the UI has a page-size list that should consume the new constant as requested by the interface. - Assistant
The UI’s page-size selector already ends at 1000 but hardcodes that value. I’ll make it derive the final option from
EVAL_TABLE_MAX_PAGE_SIZEso the server cap and UI control cannot drift. I’ll add the literal constant, apply asuperRefineto the query schema (conditional onformat), and replace the UI’s final hardcoded value/import it from the shared types alias. - Assistant
The first edit attempt could not run because Python is not installed; no files were changed. I’ll perform the same exact replacements with Node, which is available in this project, then inspect and typecheck the result.
- Assistant
The Node replacement also hit a quoting error before writing anything. I’ll simplify the generated message to string concatenation to avoid nested template-literal escaping and rerun the edit.
- Assistant
The implementation is now in place. The schema preserves coercion/default behavior, rejects only non-export limits above 1000, and accepts oversized limits when
formatiscsvorjson; the route’s existing unlimited export branch remains unchanged. I’ll run the focused schema, validation, and export tests, then TypeScript checks. - Assistant
Vitest in this repository does not support Jest’s
--runInBandoption, so the test command stopped before running any tests. I’ll rerun the same focused files with Vitest’s supported arguments, followed by typechecking and lint/diff checks. - Assistant
All four focused test files passed (72 tests). The subsequent typecheck failed only because I supplied
--incremental false, which conflicts with this repository’s composite TypeScript configuration; that is a command-line misuse rather than a code error. I’ll run the project’s normalnpm run tsc, explicitly verify the boundary and export cases with a temporary command, then run lint and inspect status/diff. - Assistant
The combined verification command was blocked by Bash history expansion on
!boundary.successbefore any subcommand executed. I’ll rerun it with the temporary TypeScript expression enclosed safely, then complete lint and diff checks. - Assistant
Normal TypeScript compilation passed, and the boundary verification confirmed: 1001 is rejected without a format, 1000 is accepted, and 1001 is accepted for CSV export. The lint invocation failed only because this script does not accept
--write=false; I’ll run the repository’s lint script without that extra argument and use Biome’s check mode on the changed TypeScript files. - Assistant
Normal lint reports pre-existing complexity warnings across unrelated files, but the changed-file check found one actionable import-order error in
ResultsTable.tsx. I’ll apply Biome’s safe import organization only to the two changed files, rerun the changed-file check, and confirm the final diff is limited to the intended implementation. - Assistant
The changed files now pass Biome checks and
git diff --check; only the intended two files are modified. The focused tests, boundary/export verification, and normal TypeScript compilation all pass. I’ll review the final diff once, then submit the completed change.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.