From 24d4d69b6c1c729a4e532fc8992767b03ede926a Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Mon, 20 Jul 2026 05:51:24 -0700 Subject: [PATCH] Add check for enabled providers in provider.ts Fixes #37922. --- packages/opencode/src/provider/provider.ts | 7 +++++-- packages/opencode/test/provider/provider.test.ts | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index a0ab5eb3474d..0c53142e2cf3 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -1395,6 +1395,7 @@ const layer = Layer.effect( if (!p || !models) continue const providerID = ProviderV2.ID.make(p.id) + if (enabled && !enabled.has(providerID)) continue if (disabled.has(providerID)) continue const provider = database[providerID] @@ -1544,7 +1545,9 @@ const layer = Layer.effect( for (const plugin of plugins) { if (!plugin.auth) continue const providerID = ProviderV2.ID.make(plugin.auth.provider) - if (disabled.has(providerID)) continue + if (!isProviderAllowed(providerID)) continue + const data = database[providerID] + if (!data) continue const stored = yield* auth.get(providerID).pipe(Effect.orDie) if (!stored) continue @@ -1553,7 +1556,7 @@ const layer = Layer.effect( const options = yield* Effect.promise(() => plugin.auth!.loader!( () => bridge.promise(auth.get(providerID).pipe(Effect.orDie)) as any, - toPublicInfo(database[plugin.auth!.provider]), + toPublicInfo(data), ), ) const opts = options ?? {} diff --git a/packages/opencode/test/provider/provider.test.ts b/packages/opencode/test/provider/provider.test.ts index 058bad23a1c6..4829f33748c4 100644 --- a/packages/opencode/test/provider/provider.test.ts +++ b/packages/opencode/test/provider/provider.test.ts @@ -152,6 +152,21 @@ it.instance( { config: { enabled_providers: ["anthropic"] } }, ) +it.instance( + "enabled_providers skips auth loaders for filtered providers", + Effect.gen(function* () { + yield* setProcessEnv( + "OPENCODE_AUTH_CONTENT", + JSON.stringify({ + google: { type: "oauth", refresh: "dummy", access: "dummy", expires: 9999999999999 }, + }), + ) + const providers = yield* list + expect(providers[ProviderV2.ID.google]).toBeUndefined() + }), + { config: { enabled_providers: ["anthropic"] } }, +) + it.instance( "model whitelist filters models for provider", Effect.gen(function* () {