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.
pull/21353/head
PabloGNU 2026-04-07 16:03:10 +02:00
parent 15e104bca8
commit 5e904080f4
1 changed files with 5 additions and 7 deletions

View File

@ -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
})