Files
OmniRoute/tests/unit/auth-noauth-fallback-loop-3061.test.ts
Tushar Agarwal 1089c24bc8 Remove/mimocode sunset provider (#10186)
* remove: drop sunset MiMoCode provider from model catalog

* remove: drop sunset MiMoCode provider from model catalog (shared.ts)

Remove unused imports, types, and comments from shared.ts.

* remove: MiMoCode provider (Xiaomi sunset) — executor, registry, no-auth config, icon, tests

* refactor(providers): finish MiMoCode removal — sweep remaining no-auth references

Drop the leftover mimocode entries from the no-auth provider controls, the
translate-path snapshot, the eslint suppressions, and the #3061 auth-loop
test. Re-point the fingerprint-pin (#6696) and proxy-noauth (#6272) tests at
opencode, which exercises the same fingerprint path, so the removal does not
break runtime behavior.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

* docs(providers): reconcile provider/executor counts after MiMoCode sunset

The base's parallel doc-count sync (#10433) pinned 340 providers / 101
executors. With mimocode removed, live code has 339 providers and 100
executors; refresh the user-facing counts (package.json description,
llm.txt, README/AGENTS, i18n llm.txt, provider reference, diagrams) so the
check-docs-counts STRICT gate stays green.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>

* test(providers): fix orphaned mimocode references after MiMoCode sunset

The sunset removed mimocode/mcode from the free-onboarding candidates and
from FINGERPRINT_PROVIDERS, but two tests still referenced them:

- free-provider-onboarding-setup: the mimocode->theoldllm substitution
  introduced duplicate 'opencode' rows (impossible given the request-set
  dedupe) and the wrong display name; align expectations with the actual
  {opencode, theoldllm} dedupe behavior and 'The Old LLM (Free)' name.
- combo-system-prompt-templates-5501: resolveTargetFingerprint tested with
  provider 'mcode', which is no longer a fingerprint provider; point it at
  the remaining fingerprint provider 'opencode'.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
Co-authored-by: Tushar49 <Tushar49@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: adevwithpurpose <adevwithpurpose@users.noreply.github.com>
Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
2026-08-18 10:49:24 -03:00

77 lines
3.4 KiB
TypeScript

/**
* Issue #3061 — No-auth providers (opencode / opencode-zen) infinite
* account-fallback loop on a persistent upstream error → unbounded DB growth /
* disk exhaustion.
*
* For a no-auth provider, getProviderCredentials early-returns synthetic
* credentials with connectionId "noauth" BEFORE honoring the exclusion set
* (src/sse/services/auth.ts: the NOAUTH_PROVIDERS block and the opencode-zen
* keyless fallback). So when the chat fallback loop marks the failed "noauth"
* connection and excludes it, the selector hands "noauth" right back → it loops
* forever, writing key-health + request logs every iteration until the disk
* fills (see @paraflu's "failure #320" trace in discussion #3038).
*
* Loop-breaking invariant under test: once "noauth" is in excludeConnectionIds,
* the selector MUST return null (no remaining candidate) so the chat handler
* stops after a single attempt instead of re-selecting the same synthetic
* connection. The happy-path (nothing excluded → synthetic noauth) must stay
* intact so keyless access still works.
*/
import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-noauth-loop-3061-"));
process.env.DATA_DIR = TEST_DATA_DIR;
const core = await import("../../src/lib/db/core.ts");
const { getProviderCredentials } = await import("../../src/sse/services/auth.ts");
test.after(() => {
core.resetDbInstance();
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
});
// ── Happy path preserved: first selection (nothing excluded) still works ──
test("#3061 opencode no-auth: first selection returns synthetic noauth (happy path preserved)", async () => {
const creds = await getProviderCredentials("opencode", null, null, "minimax-m2.5-free");
assert.ok(creds, "opencode must resolve to synthetic no-auth credentials on first selection");
assert.equal((creds as { connectionId?: string }).connectionId, "noauth");
assert.equal((creds as { apiKey?: unknown }).apiKey, null);
});
test("#3061 opencode-zen no-auth: first selection returns synthetic noauth (happy path preserved)", async () => {
const creds = await getProviderCredentials("opencode-zen");
assert.ok(creds, "opencode-zen must resolve to synthetic no-auth credentials on first selection");
assert.equal((creds as { connectionId?: string }).connectionId, "noauth");
});
// ── The fix: once "noauth" is excluded, selection MUST stop (return null) ──
test("#3061 opencode no-auth: excluding 'noauth' returns null (breaks the fallback loop)", async () => {
const creds = await getProviderCredentials("opencode", null, null, "minimax-m2.5-free", {
excludeConnectionIds: ["noauth"],
});
assert.equal(
creds,
null,
"after the synthetic noauth connection failed and was excluded, the selector must return " +
"null instead of handing back 'noauth' (which would loop forever and fill the disk)"
);
});
test("#3061 opencode-zen no-auth: excluding 'noauth' returns null (breaks the fallback loop)", async () => {
const creds = await getProviderCredentials("opencode-zen", null, null, null, {
excludeConnectionIds: ["noauth"],
});
assert.equal(
creds,
null,
"excluded synthetic noauth must not be re-selected for the opencode-zen keyless path"
);
});