Reject model IDs unsafe for headers and clarify supported capabilities
All checks were successful
CI / test (22) (push) Successful in 22s
CI / test (24) (push) Successful in 21s

This commit is contained in:
Benjamin Hackl 2026-11-03 21:46:37 +01:00
commit 7754377b3e

View file

@ -58,6 +58,20 @@ test("skips unusable entries but rejects malformed or entirely unusable catalogs
}
});
test("catalog IDs must fit Fetch's Latin-1 header values", () => {
const valid = ["gpt-4o", "model-\u00ff"];
const invalid = ["model-\u0100", "model-\u{1f600}", "model-\ud800"];
const parsed = parseCatalog({ data: [...valid, ...invalid].map((id) => ({ id })) });
assert.deepEqual(parsed, { ids: valid, skipped: invalid.length });
for (const id of parsed.ids) {
const headers = new Headers(makeModel(id, BASE_URL).headers);
assert.equal(headers.get("deployment-id"), id);
}
for (const id of invalid) {
assert.throws(() => parseCatalog({ data: [{ id }] }), /without any valid model IDs/);
}
});
const known: Record<string, ModelMetadata> = {
"model-a": { name: "Model A", input: ["text", "image"], contextWindow: 272_000, maxTokens: 128_000 },
};