Files
OmniRoute/tests/unit/bytez-validation-5422.test.ts
Diego Rodrigues de Sa e Souza 0adae00c7b Release v3.8.42 (#5459)
Release v3.8.42 — full CHANGELOG in CHANGELOG.md.

CI: 103 checks green incl. CodeQL (all languages), Semgrep, all 8 unit shards,
coverage, Node 24 compat, and integration tests. Full unit suite validated
locally: 19437 pass / 0 fail. The 3 red checks are advisory and do not gate
main (no required status checks): SonarCloud/SonarQube new-code coverage gate,
and PR Test Policy (test-masking detector flagging the legitimate dead-Phind
provider removal in #5530 — reviewed, correct).

Includes cycle-close reconciliation + repair of inherited base-red tests from
#5480/#5527/#5427/#5521 that the PR->release fast-path did not exercise.
2026-06-30 06:54:29 -03:00

46 lines
2.0 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { bytezValidationResultFromStatus } from "../../src/lib/providers/validation.ts";
import { bytezProvider } from "../../open-sse/config/providers/registry/bytez/index.ts";
// #5422 — Bytez key validation cannot use a chat probe. A Bytez account only serves models
// that have been added to its catalog, so even Bytez's own documented model ids return 404
// ("Model does not exist or has yet to be added to the Bytez catalog") for a fresh/free key —
// the generic OpenAI-like chat probe misreads that 404 as "endpoint not supported". The fix
// validates against the model-independent, auth-only tasks endpoint instead (verified live):
// GET …/models/v2/list/tasks → 200 (valid key) | 401 { error: "Unauthorized" } (invalid).
// The pure status→result mapping below is the unit-testable core of that validator.
test("#5422 bytez status→result: 200 is valid", () => {
assert.deepEqual(bytezValidationResultFromStatus(200), { valid: true, error: null });
});
test("#5422 bytez status→result: 401/403 is an invalid API key", () => {
assert.deepEqual(bytezValidationResultFromStatus(401), {
valid: false,
error: "Invalid API key",
});
assert.deepEqual(bytezValidationResultFromStatus(403), {
valid: false,
error: "Invalid API key",
});
});
test("#5422 bytez status→result: other non-OK is a generic validation failure", () => {
assert.deepEqual(bytezValidationResultFromStatus(500), {
valid: false,
error: "Validation failed: 500",
});
});
// Part A — the registry baseUrl must carry the full OpenAI-compat chat path so chat resolves
// once an account has catalog models (the bare `…/models/v2` base made the probe hit
// `…/models/v2/chat/completions` → 404).
test("#5422 bytez registry baseUrl carries the full OpenAI-compat chat path", () => {
assert.ok(
bytezProvider.baseUrl.endsWith("/models/v2/openai/v1/chat/completions"),
`baseUrl must end with the OpenAI-compat chat path, got: ${bytezProvider.baseUrl}`
);
});