mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-15 03:12:36 +03:00
`main` has been red since b342c1a361 on the vitest and integration gates:
✖ tests/unit/autoCombo/provider-family-combos.test.ts > auto/<family>
✖ chat pipeline applies Codex OAuth fingerprint and priority tier inside combos
Both call resetStorage() from beforeEach, which does an fs.rmSync(TEST_DATA_DIR,
{recursive: true, force: true}) with no retry, and intermittently loses the race
with a not-yet-released SQLite handle (ENOTEMPTY).
release/v3.8.51 fixed this in #11968 with a mechanical codemod adding
maxRetries/retryDelay to every recursive rm/rmSync/rmdirSync under tests/, but
that PR landed only on the release branch. Because main only receives work at
the release squash, it stayed broken for the whole cycle — and repo-wide gates
then turn every open PR into main red on checks unrelated to their diff.
This is the --base main twin: re-runs the same codemod that already shipped on
the release branch (scripts/ad-hoc/codemod-rm-maxretries.mjs), so the two
branches converge on identical test-teardown semantics. Test-only; no product
logic is touched.
The remaining three failures reported on #12133 (unit full suite exceeding its
4800s ceiling, package-artifact exceeding 1200s, and the boot-smoke that is
skipped as a consequence) are runner-contention timeouts, not code defects —
validate-release-green.mjs runs those heavy gates concurrently on one shared
hosted runner. There is no fix to port for those.
78 lines
3.2 KiB
TypeScript
78 lines
3.2 KiB
TypeScript
/**
|
|
* Issue #2962 — Playground cannot use the OpenCode free model:
|
|
* "No credentials for the provider: opencode-zen".
|
|
*
|
|
* opencode-zen serves the public, signup-free OpenCode Zen endpoint
|
|
* (https://opencode.ai/zen/v1). When no API-key connection is configured,
|
|
* getProviderCredentials returned null → the chat handler surfaced
|
|
* "No credentials for provider: opencode-zen". It must instead fall back to
|
|
* anonymous (no-auth) credentials so the free tier 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-opencode-zen-noauth-"));
|
|
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");
|
|
const { createProviderConnection } = await import("../../src/lib/db/providers.ts");
|
|
|
|
test.after(() => {
|
|
core.resetDbInstance();
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
});
|
|
|
|
test("#2962 opencode-zen with no connection falls back to anonymous no-auth credentials", async () => {
|
|
const creds = await getProviderCredentials("opencode-zen");
|
|
assert.ok(creds, "opencode-zen must resolve to credentials, not null (no-auth free tier)");
|
|
assert.equal(
|
|
(creds as { connectionId?: string }).connectionId,
|
|
"noauth",
|
|
"should be synthetic no-auth credentials"
|
|
);
|
|
assert.equal((creds as { apiKey?: unknown }).apiKey, null, "anonymous access carries no api key");
|
|
});
|
|
|
|
test("apikey providers with anonymous fallback use no-auth when saved rows are terminal", async () => {
|
|
await createProviderConnection({
|
|
provider: "pollinations",
|
|
authType: "apikey",
|
|
name: "expired-pollinations-key",
|
|
apiKey: "pollinations-expired",
|
|
isActive: true,
|
|
testStatus: "expired",
|
|
});
|
|
|
|
const creds = await getProviderCredentials("pollinations");
|
|
assert.ok(creds, "pollinations should fall back to anonymous credentials");
|
|
assert.equal((creds as { connectionId?: string }).connectionId, "noauth");
|
|
assert.equal((creds as { apiKey?: unknown }).apiKey, null);
|
|
});
|
|
|
|
test("#2962 a normal api-key provider with no connection still returns null (no over-broadening)", async () => {
|
|
const creds = await getProviderCredentials("openai");
|
|
// Must NOT synthesize no-auth creds for a real api-key provider.
|
|
const connectionId = (creds as { connectionId?: string } | null)?.connectionId;
|
|
assert.notEqual(connectionId, "noauth", "openai must not get anonymous no-auth credentials");
|
|
});
|
|
|
|
test("#2962 opencode-zen falls back to no-auth when saved key rows are unusable", async () => {
|
|
await createProviderConnection({
|
|
provider: "opencode-zen",
|
|
authType: "apikey",
|
|
name: "expired-test-key",
|
|
apiKey: "oa_test_expired",
|
|
isActive: true,
|
|
testStatus: "expired",
|
|
});
|
|
|
|
const creds = await getProviderCredentials("opencode-zen");
|
|
assert.ok(creds, "opencode-zen should still resolve to anonymous no-auth credentials");
|
|
assert.equal((creds as { connectionId?: string }).connectionId, "noauth");
|
|
assert.equal((creds as { apiKey?: unknown }).apiKey, null);
|
|
});
|