Repository navigation
fix(ai-gateway): bound and normalize opt-out model entries at the admin write boundary - #8725
Conversation
…rite schema The admin set-mutation input now applies the same element rule the stored and hot-path readers require, and owns the stored form of the list: trimmed, lowercase, non-empty, length-bounded, capped, and duplicate-free.
The routing form validates its submission with the write schema before the mutation and renders the field error in the admin validation block; a rejected request shows the server's field message.
Adds schema cases for blank, over-length, and over-count entries, duplicate collapsing, and a round-trip through both read schemas, plus a router case that a refused input writes nothing.
|
bot: Verified the admin Gateway routing form on the local dev stack with an owned fake admin account.
Both captures are scoped to the routing card; the card text was checked for excluded-feature content before capture. |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe incremental commit only relocates the opt-out validation alert into its field section and wires Assumptions: Targeted verification only for unchanged files from the prior review; no test suite or dev stack was available to execute in this read-only session. Files Reviewed (1 file)
Previous Review Summary (commit 71d3d2b)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 71d3d2b)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe bounds and normalization added around the admin routing write boundary are sound and covered by tests; the only finding is that the new form validation error is not associated with the opt-out field it describes. Assumptions: Zod 4 string-transform ordering ( Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (5 files)
Reviewed by deepseek-flash-latest · Input: 24.3K · Output: 1.4K · Cached: 112.4K Review guidance: REVIEW.md from base branch |
The validation block now renders inside the opt-out section, and the textarea advertises the error through aria-describedby and aria-invalid.
|
bot: Updated capture after the review fix (a34301c): the field error now renders inside the opt-out section, and the textarea advertises it through |



Evidence
Evidence: demonstrated — the admin write contract was compared with both read schemas over one stored routing value, and the admin Gateway routing form was driven in Chromium on the local dev stack with an owned fake admin account: a submission beyond the entry limit renders the field error inline and writes no row, and a valid list saves, normalizes, and reloads from Postgres in that form. Captures are scoped to the routing card, and the card text was checked for excluded-feature content before capture.
Change
GatewayConfigInputSchema.vercel_routing_opt_out_modelsnow requires trimmed, non-empty entries of at mostVERCEL_ROUTING_OPT_OUT_MODEL_MAX_LENGTH(200) characters, caps the list atVERCEL_ROUTING_OPT_OUT_MODELS_MAX_COUNT(200), lowercases entries, and collapses duplicates. Every accepted input therefore parses withGatewayConfigSchemaandGatewayRoutingConfigSchema.setmutation stores the validated list as-is: the write schema is the single place that defines the stored form, and the router no longer carries its own normalization.prewithrole="alert"), and reports server-side rejection throughformatZodError.Tests
packages/web-shared/src/lib/ai-gateway/gateway-config.test.ts: blank and whitespace entries, an over-length entry, and an over-count list are refused; an entry at the length boundary is accepted; entries are trimmed, lowercased, and collapsed; an accepted input round-trips through both read schemas.apps/web/src/routers/admin/gateway-config-router.test.ts:setstores the normalized list,getreturns it, and a refused input writes nothing.pnpm --filter @kilocode/web-shared typecheck,pnpm --filter web typecheck, oxlint and oxfmt on the changed paths, and both jest suites (23 tests).Proxy answers
Answer: 200 entries, 200 characters each.
Confidence: 0.75
Answer: Leave the read schemas permissive.
Confidence: 0.60
Answer: In the input schema, with the router dropping its own normalization.
Confidence: 0.75