different-ai/openwork · error

`${t("providers.unknown_provider")}: ${resolved}`

Error message

`${t("providers.unknown_provider")}: ${resolved}`

What it means

After resolving the providerId, startProviderOAuth looks up authMethods[resolved]; if the provider is absent from the server's method list (or its list is empty), the store throws "unknown provider: <id>". The providerId passed is not one the connected server offers for authentication.

Source

Thrown at apps/app/src/react-app/domains/connections/provider-auth/store.ts:1420

    try {
      const cachedMethods = state.providerAuthMethods;
      const authMethods = Object.keys(cachedMethods).length
        ? cachedMethods
        : await loadProviderAuthMethods(getProviderAuthWorkerType());
      const providerIds = Object.keys(authMethods).sort();
      if (!providerIds.length) {
        throw new Error(t("providers.no_providers_available"));
      }

      const resolved = providerId?.trim() ?? "";
      if (!resolved) {
        throw new Error(t("providers.provider_id_required"));
      }
      assertProviderAllowedByDesktopPolicy(resolved);

      const methods = authMethods[resolved];
      if (!methods || !methods.length) {
        throw new Error(`${t("providers.unknown_provider")}: ${resolved}`);
      }

      const oauthIndex =
        methodIndex !== undefined
          ? methodIndex
          : methods.find((method) => method.type === "oauth")?.methodIndex ?? -1;
      if (oauthIndex === -1) {
        throw new Error(
          `${t("providers.no_oauth_prefix")} ${resolved}. ${t("providers.use_api_key_suffix")}`,
        );
      }

      const selectedMethod = methods.find((method) => method.methodIndex === oauthIndex);
      if (!selectedMethod || selectedMethod.type !== "oauth") {
        throw new Error(`${t("providers.not_oauth_flow_prefix")} ${resolved}.`);
      }

      const auth = unwrap(

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Use a provider id exactly as listed by c.provider.auth() (inspect the returned map).
  2. Configure the provider on the opencode server so it exposes auth methods.
  3. Clear the cached state.providerAuthMethods and reload so the list reflects the current server.
  4. Verify the desktop policy allows the provider (assertProviderAllowedByDesktopPolicy runs before this check, so policy is not the cause here — the server list is).

Example fix

// before
await startProviderOAuth("Anthropic");
// after
await startProviderOAuth("anthropic"); // must match server key
Defensive patterns

Strategy: validation

Validate before calling

const authMethods = await store.loadProviderAuthMethods(workerType);
if (!(providerId in authMethods) || authMethods[providerId].length === 0) {
  showToast(`Provider "${providerId}" is not available on this server.`);
  return;
}
await store.startProviderOAuth(providerId);

Type guard

function isKnownProvider(m: Record<string, ProviderAuthMethod[]>, id: string): id is keyof typeof m & string {
  return Boolean(m[id]?.length);
}

Try / catch

try {
  await store.startProviderOAuth(providerId);
} catch (e) {
  if (e instanceof Error && /unknown provider/i.test(e.message)) {
    showToast(e.message);
    void store.refreshProviderAuthMethods();
  } else throw e;
}

Prevention

When it happens

Trigger: Calling startProviderOAuth with a providerId that is not a key of the map returned by c.provider.auth() (fetched fresh or from the state cache), or whose ProviderAuthMethod array is empty.

Common situations: Typo in provider id ('anthropic' vs 'anthropic-ai'); provider exists in models list but has no auth methods on this server; provider allowed by desktop policy but not configured server-side; stale cached providerAuthMethods from a previous server whose providers changed.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/5e411d919ef0ea66. Report an issue: GitHub.