{"record":{"id":"8a547422e2d60891","repo":"mastra-ai/mastra","slug":"unknown-oauth-provider-providerid","errorCode":null,"errorMessage":"Unknown OAuth provider: ${providerId}","messagePattern":"Unknown OAuth provider: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/sdk/src/auth/storage.ts","lineNumber":193,"sourceCode":"   */\n  loadStoredApiKeysIntoEnv(providerEnvVars: Record<string, string | undefined>): void {\n    for (const [key, cred] of Object.entries(this.data)) {\n      if (!key.startsWith('apikey:') || cred.type !== 'api_key' || !cred.key) continue;\n      const provider = key.substring('apikey:'.length);\n      const envVar = providerEnvVars[provider];\n      if (envVar && !process.env[envVar]) {\n        process.env[envVar] = cred.key;\n      }\n    }\n  }\n\n  /**\n   * Login to an OAuth provider.\n   */\n  async login(providerId: OAuthProviderId, callbacks: OAuthLoginCallbacks): Promise<void> {\n    const provider = getOAuthProvider(providerId);\n    if (!provider) {\n      throw new Error(`Unknown OAuth provider: ${providerId}`);\n    }\n\n    const credentials = await provider.login(callbacks);\n    this.set(providerId, { type: 'oauth', ...credentials });\n  }\n\n  /**\n   * Logout from a provider.\n   */\n  logout(provider: string): void {\n    this.remove(provider);\n  }\n\n  /**\n   * Get API key for a provider, auto-refreshing OAuth tokens if needed.\n   */\n  async getApiKey(providerId: string): Promise<string | undefined> {\n    const cred = this.data[providerId];","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/sdk/src/auth/storage.ts#L175-L211","documentation":"OAuthStorage.login looks up the provider implementation via getOAuthProvider(providerId). If no provider is registered under that id, it throws before any network call. Only ids registered in the provider registry are valid.","triggerScenarios":"Calling storage.login(providerId, callbacks) with a providerId string that is not one of the registered OAuthProviderId values (typo, wrong casing, or unregistered custom provider).","commonSituations":"Hardcoded provider string like 'openai' instead of the exact id (e.g. 'openai-codex'); dynamically loaded provider not registered before login; config file value not matching known ids; version change renaming an id.","solutions":["Use one of the registered OAuthProviderId values exactly (check getOAuthProvider/registry for the list).","Fix typos/casing in the provider id string.","If using a custom provider, register it with the registry before calling login.","Verify the SDK version hasn't renamed provider ids; update calling code accordingly."],"exampleFix":"// before\nawait storage.login('openai' as any, callbacks);\n// after\nawait storage.login('openai-codex', callbacks); // exact registered provider id","handlingStrategy":"validation","validationCode":"const KNOWN = ['openai-codex', 'xai'] as const; // registered OAuthProviderId values\nfunction isRegisteredProvider(id: string): id is typeof KNOWN[number] {\n  return (KNOWN as readonly string[]).includes(id);\n}\nif (!isRegisteredProvider(providerId)) throw new Error(`Provider \"${providerId}\" is not registered`);","typeGuard":"function isOAuthProviderId(id: string): id is OAuthProviderId {\n  return getOAuthProvider(id as OAuthProviderId) !== undefined;\n}","tryCatchPattern":"try {\n  await storage.login(providerId, callbacks);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unknown OAuth provider')) {\n    console.error(`Provider \"${providerId}\" unavailable; valid ids: ${listProviderIds().join(', ')}`);\n  }\n}","preventionTips":["Reference provider ids from exported constants/types instead of string literals","Check the provider registry (getOAuthProvider) for valid ids before calling login","Register any custom provider before invoking login","Grep for provider id usages when upgrading the SDK in case ids were renamed"],"tags":["oauth","configuration","provider-registry"],"backgroundTag":"unknown-oauth-provider","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}