Files
OmniRoute/tests/unit/auth-opencode-zen-noauth-fallback.test.ts
Diego Rodrigues de Sa e Souza 929caeb910 Release v3.8.15 (#3373)
* chore(release): open v3.8.15 development cycle

Version bump 3.8.14 -> 3.8.15 (root + electron + open-sse + openapi + lockfiles)
and seed the v3.8.15 changelog placeholder (root + 41 i18n mirrors).

* fix(catalog): add getTokenLimit fallback for combo targets with unknown context (#3369)

Integrated into release/v3.8.15. Fixes applied on the contributor's branch: removed duplicate JSDoc opening in accountFallback.ts and dropped a test asserting unreachable catalog behavior (models with no registry/spec/synced source are filtered before the getTokenLimit fallback at catalog.ts:499).

* fix(combo): add 429 to PROVIDER_FAILURE_ERROR_CODES to prevent infinite retry loop (#3366)

Integrated into release/v3.8.15. Comment block reconciled on the contributor's branch to remove the contradictory 'intentionally excluded' text that remained from the original code.

* fix(auto-combo): include no-auth providers declaratively (#3365)

Integrated into release/v3.8.15. Cleanup applied on contributor's branch: removed duplicate migration 095 (already exists from PR #3338), reverted CHANGELOG.md and i18n changelogs to release versions (release process owns these), dropped package version-bump noise from stale fork base. Core feature — declarative no-auth via serviceKinds metadata, declarative VEO as 'video' provider, anonymousFallback flag for opencode-zen/opencode-go — integrated cleanly.

* fix(migrations): restore 095_provider_node_custom_headers migration

The squash merge of PR #3365 accidentally deleted this migration because
the cleanup commit on the contributor's branch included 'git rm' for the
file (which was a duplicate on their branch). The migration was merged
in v3.8.14 via PR #3338 and must be present in the release branch.

Restoring from git history.

* fix: update Command Code base URL from /alpha/ to /provider/v1/ (#3372)

Integrated into release/v3.8.15.

* feat(error-rules): provider-specific error classification with scope (#3370)

Integrated into release/v3.8.15. PR has genuine value beyond #3369: (1) getProviderErrorRuleMatch now accepts native Headers objects from fetch(); (2) checkFallbackError also uses the provider rule registry — the real end-to-end wiring in the combo fallback path; (3) S4 end-to-end test proving the wiring fires. Merge commit on contributor branch resolved the add/add conflict by taking the #3370 version throughout.

* fix(auto-combo): validate web-session credentials (#3371)

Integrated into release/v3.8.15. Core feature: provider-aware web-session credential validation — hasUsableWebSessionCredential() replaces the broad Object.keys check in virtualFactory.ts, ensuring only sessions with the required storageKeys are included in auto-combo. Cleanup: removed duplicate 095 migration, reverted CHANGELOG/i18n, dropped package bump noise.

* fix(migrations): restore 095_provider_node_custom_headers (deleted again by #3371 squash)

Same issue as after #3365: git rm in the contributor cleanup commit
was included in the squash, deleting this migration from release.
Permanent fix needed: use 'git checkout origin/release -- <file>'
instead of 'git rm' when cleaning up duplicate files in contributor branches.

* fix(kiro): probe Windows %APPDATA%\kiro\storage.db in auto-import (#3363) (#3375)

Integrated into release/v3.8.15. Test fix applied: kiro-windows-auto-import-3363.test.ts now sets DATA_DIR to a fresh temp dir before importing app modules, ensuring isAuthRequired() sees an empty settings DB (no password → auth not required). This fixed test 4 (synthetic SQLite) which was getting 401 due to settings DB state leakage.

* chore(release): finalize v3.8.15 changelog — 2026-06-07

---------

Co-authored-by: Hernan Javier Ardila Sanchez <hjasgr@gmail.com>
Co-authored-by: Paijo <14921983+oyi77@users.noreply.github.com>
Co-authored-by: Muhammad Nabil Muyassar Rahman <65392758+TapZe@users.noreply.github.com>
Co-authored-by: kiro-agent[bot] <245459735+kiro-agent[bot]@users.noreply.github.com>
2026-06-07 12:16:33 -03:00

78 lines
3.1 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 });
});
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);
});