From 5e904080f4f9c032c039ff3499d2630dbbd2b53e Mon Sep 17 00:00:00 2001 From: PabloGNU Date: Tue, 7 Apr 2026 16:03:10 +0200 Subject: [PATCH] fix: Auth.get fallback chain for profile keys When looking up auth credentials: - If profile key exists (e.g., 'minimax-coding-plan:personal'), use it - If profile key doesn't exist but base provider does (e.g., 'minimax-coding-plan'), use that as fallback This fixes the issue where build mode (no profile) wouldn't work when only 'minimax-coding-plan:personal' existed in auth.json. Also removes normalizeKey usage from Auth.get - the fallback logic is now inline and clearer. --- packages/opencode/src/auth/index.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/opencode/src/auth/index.ts b/packages/opencode/src/auth/index.ts index 95f784cd67..415e1767b9 100644 --- a/packages/opencode/src/auth/index.ts +++ b/packages/opencode/src/auth/index.ts @@ -71,19 +71,17 @@ export namespace Auth { const get = Effect.fn("Auth.get")(function* (providerID: string) { const allData = yield* all() + const bare = providerID.replace(/\/+$/, "") // Direct lookup (original behavior for backward compat with bare keys) - if (providerID in allData) return allData[providerID] - const withSlash = providerID.endsWith("/") ? providerID.slice(0, -1) : providerID + "/" + if (bare in allData) return allData[bare] + const withSlash = bare.endsWith("/") ? bare.slice(0, -1) : bare + "/" if (withSlash in allData) return allData[withSlash] // Multi-profile support: if key has embedded profile (provider:profile), try direct if (providerID.includes(":")) { if (providerID in allData) return allData[providerID] + // Profile specified but not found - try base provider without profile + if (bare in allData) return allData[bare] } - // Multi-profile support: try normalized key with :default - const withProfile = normalizeKey(providerID) - if (withProfile in allData) return allData[withProfile] - const bare = providerID.replace(/\/+$/, "") - if (`${bare}:default` in allData) return allData[`${bare}:default`] return undefined })