Files
OmniRoute/tests/unit/errorClassifier-noauth-403-6315.test.ts
Praveen K Palaniswamy 65e81158ab fix(ollama): route models by advertised capability (#11088)
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host.

Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean.

Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
2026-08-23 11:45:01 -03:00

52 lines
2.1 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import {
classifyProviderError,
PROVIDER_ERROR_TYPES,
} from "../../open-sse/services/errorClassifier.ts";
// #6315 / #6345 — a single generic upstream 403 on a no-credential ("authType:
// none") provider was permanently banning the whole
// connection (classified as FORBIDDEN, a terminal type). These providers are
// free/stateless — there is no real account/credential to revoke, so a bare
// 403 should be RECOVERABLE (null) and handled by the existing connection
// cooldown/retry layer, same as apikey providers already are.
test("#6345: theoldllm 'Request blocked'/access_denied 403 -> recoverable (null), not FORBIDDEN", () => {
const body = { error: "Request blocked", type: "access_denied" };
assert.equal(classifyProviderError(403, body, "theoldllm"), null);
});
test("control: apikey-provider bare 403 still recoverable (null) — no regression", () => {
assert.equal(classifyProviderError(403, "forbidden", "openai"), null);
});
test("#8813: chatgpt-web SENTINEL_BLOCKED 403 with 'Sentinel/Turnstile required' → FORBIDDEN (terminal)", () => {
// The executor returns error code "SENTINEL_BLOCKED" in the JSON body.
// This is a TERMINAL state — retrying the same blocked session will keep 403ing.
// Must be classified as FORBIDDEN so the circuit breaker marks the connection
// as banned and combo routing falls back to other providers.
const body = JSON.stringify({
error: {
message:
"ChatGPT blocked the request (Sentinel/Turnstile required). Try again later or open chatgpt.com in a browser to refresh state.",
type: "upstream_error",
code: "SENTINEL_BLOCKED",
},
});
assert.equal(
classifyProviderError(403, body, "chatgpt-web"),
PROVIDER_ERROR_TYPES.FORBIDDEN
);
});
test("#8813: chatgpt-web SENTINEL_BLOCKED 403 with raw 'Sentinel blocked' text → FORBIDDEN (terminal)", () => {
// Edge case: when the raw text includes "Sentinel" and 403, classify as terminal.
assert.equal(
classifyProviderError(403, "Sentinel blocked the request", "chatgpt-web"),
PROVIDER_ERROR_TYPES.FORBIDDEN
);
});