Files
OmniRoute/tests/unit/columns-validation.test.ts
Dizzle f3b190ba3e fix(providers): reject silent validation degradation with 400 and rejected keys (#11101)
Validated on the combined batch board over release/v3.8.50 tip d91238b7: static gates clean, typecheck:core clean, focused tests green.

Strict schema + {sanitized, rejected} DB boundary — silent validation degradation now answers 400 with the offending keys. Caller audit done: only the providers write path consumes the sanitizers. Thank you @maxmad64bis!
2026-08-22 14:39:58 -03:00

25 lines
906 B
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import {
sanitizeRateLimitOverrides,
sanitizeQuotaWindowThresholds,
} from "@/lib/db/providers/columns";
test("sanitizeRateLimitOverrides surfaces rejected keys (blocking, not silent)", () => {
const r = sanitizeRateLimitOverrides({ rpm: 10, foo: 1, tpm: -1 });
assert.deepEqual(r.sanitized, { rpm: 10 });
assert.deepEqual(r.rejected.sort(), ["foo", "tpm"]);
});
test("sanitizeQuotaWindowThresholds surfaces key-too-long and out-of-range", () => {
const r = sanitizeQuotaWindowThresholds({ ["a".repeat(65)]: 50, win: 101 });
assert.ok(r.rejected.length >= 1);
assert.ok(r.rejected.includes("win"));
});
test("valid input yields no rejected keys", () => {
const r = sanitizeRateLimitOverrides({ rpm: 10, tpm: 20 });
assert.deepEqual(r.rejected, []);
assert.deepEqual(r.sanitized, { rpm: 10, tpm: 20 });
});