{"record":{"id":"5e411d919ef0ea66","repo":"different-ai/openwork","slug":"t-providers-unknown-provider-resolved","errorCode":null,"errorMessage":"`${t(\"providers.unknown_provider\")}: ${resolved}`","messagePattern":"`\\$\\{t\\(\"providers\\.unknown_provider\"\\)\\}: \\$\\{resolved\\}`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/connections/provider-auth/store.ts","lineNumber":1420,"sourceCode":"    try {\n      const cachedMethods = state.providerAuthMethods;\n      const authMethods = Object.keys(cachedMethods).length\n        ? cachedMethods\n        : await loadProviderAuthMethods(getProviderAuthWorkerType());\n      const providerIds = Object.keys(authMethods).sort();\n      if (!providerIds.length) {\n        throw new Error(t(\"providers.no_providers_available\"));\n      }\n\n      const resolved = providerId?.trim() ?? \"\";\n      if (!resolved) {\n        throw new Error(t(\"providers.provider_id_required\"));\n      }\n      assertProviderAllowedByDesktopPolicy(resolved);\n\n      const methods = authMethods[resolved];\n      if (!methods || !methods.length) {\n        throw new Error(`${t(\"providers.unknown_provider\")}: ${resolved}`);\n      }\n\n      const oauthIndex =\n        methodIndex !== undefined\n          ? methodIndex\n          : methods.find((method) => method.type === \"oauth\")?.methodIndex ?? -1;\n      if (oauthIndex === -1) {\n        throw new Error(\n          `${t(\"providers.no_oauth_prefix\")} ${resolved}. ${t(\"providers.use_api_key_suffix\")}`,\n        );\n      }\n\n      const selectedMethod = methods.find((method) => method.methodIndex === oauthIndex);\n      if (!selectedMethod || selectedMethod.type !== \"oauth\") {\n        throw new Error(`${t(\"providers.not_oauth_flow_prefix\")} ${resolved}.`);\n      }\n\n      const auth = unwrap(","sourceCodeStart":1402,"sourceCodeEnd":1438,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/connections/provider-auth/store.ts#L1402-L1438","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use a provider id exactly as listed by c.provider.auth() (inspect the returned map).","Configure the provider on the opencode server so it exposes auth methods.","Clear the cached state.providerAuthMethods and reload so the list reflects the current server.","Verify the desktop policy allows the provider (assertProviderAllowedByDesktopPolicy runs before this check, so policy is not the cause here — the server list is)."],"exampleFix":"// before\nawait startProviderOAuth(\"Anthropic\");\n// after\nawait startProviderOAuth(\"anthropic\"); // must match server key","handlingStrategy":"validation","validationCode":"const authMethods = await store.loadProviderAuthMethods(workerType);\nif (!(providerId in authMethods) || authMethods[providerId].length === 0) {\n  showToast(`Provider \"${providerId}\" is not available on this server.`);\n  return;\n}\nawait store.startProviderOAuth(providerId);","typeGuard":"function isKnownProvider(m: Record<string, ProviderAuthMethod[]>, id: string): id is keyof typeof m & string {\n  return Boolean(m[id]?.length);\n}","tryCatchPattern":"try {\n  await store.startProviderOAuth(providerId);\n} catch (e) {\n  if (e instanceof Error && /unknown provider/i.test(e.message)) {\n    showToast(e.message);\n    void store.refreshProviderAuthMethods();\n  } else throw e;\n}","preventionTips":["Populate provider pickers from the server's method map, never from a hardcoded list.","Match provider ids exactly (lowercase ids like 'anthropic').","Refresh cached providerAuthMethods when the server config changes.","Validate the id against the current server list before calling the action."],"tags":["validation","provider-id","provider-auth"],"backgroundTag":"unknown-provider-id","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}