{"record":{"id":"af07f7fc3c36546a","repo":"mem0ai/mem0","slug":"invalid-provider","errorCode":null,"errorMessage":"Invalid provider","messagePattern":"Invalid provider","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"integrations/vercel-ai-sdk/src/provider-response-provider.ts","lineNumber":67,"sourceCode":"                    apiKey: config?.apiKey,\n                    ...provider_config as AnthropicProviderSettings,\n                }).languageModel(modelId);\n                break;\n            case \"groq\":\n                this.languageModel = createGroq({\n                    apiKey: config?.apiKey,\n                    ...provider_config as GroqProviderSettings,\n                })(modelId);\n                break;\n            case \"google\":\n            case \"gemini\":\n                this.languageModel = createGoogleGenerativeAI({\n                    apiKey: config?.apiKey,\n                    ...provider_config as GoogleGenerativeAIProviderSettings,\n                })(modelId);\n                break;\n            default:\n                throw new Error(\"Invalid provider\");\n        }\n    }\n\n    async doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult> {\n        const result = await this.languageModel.doGenerate(options);\n        return result as LanguageModelV3GenerateResult;\n    }\n\n    async doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult> {\n        const result = await this.languageModel.doStream(options);\n        return result as LanguageModelV3StreamResult;\n    }\n}\n\nexport type ProviderSettings = OpenAIProviderSettings | CohereProviderSettings | AnthropicProviderSettings | GroqProviderSettings | GoogleGenerativeAIProviderSettings;\nexport default Mem0AITextGenerator;\n","sourceCodeStart":49,"sourceCodeEnd":84,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/integrations/vercel-ai-sdk/src/provider-response-provider.ts#L49-L84","documentation":"Mem0AITextGenerator's constructor in provider-response-provider.ts instantiates the real underlying LLM via a switch over the provider name and falls through to `throw new Error(\"Invalid provider\")` when the name matches no case. This is the last-line dispatch guard: it fires when the selector's supportedProviders list accepted a name that the constructor's switch does not actually handle.","triggerScenarios":"config.provider passes Mem0ClassSelector.supportedProviders but the switch in this file only wires openai/anthropic/groq/google(gemini) — e.g. a version skew between the selector list and this switch, or a provider name that differs only by alias casing.","commonSituations":"Installing mismatched versions of the integration packages; adding a provider to supportedProviders via patch/fork without extending the switch; passing 'google' where the switch expects 'gemini' or vice versa (both are handled here, but aliases drift across versions).","solutions":["Pin the integration to one version where the selector list and constructor switch agree.","Use one of the explicitly wired providers: openai, anthropic, groq, or google/gemini.","If you forked or patched supportedProviders, add the matching case to this switch too.","Report the version-skew bug upstream with the provider string that reproduced it."],"exampleFix":"// before\nconst provider = createMem0Provider({ provider: \"mistral\" }); // may pass selector, fail here\n\n// after\nconst provider = createMem0Provider({ provider: \"openai\" });","handlingStrategy":"validation","validationCode":"const WIRED_PROVIDERS = new Set(['openai', 'anthropic', 'groq', 'google', 'gemini']);\nfunction assertProviderWired(p: string): void {\n  if (!WIRED_PROVIDERS.has(p)) throw new Error(`Provider '${p}' not wired in provider-response-provider`);\n}","typeGuard":"const isWiredProvider = (p: unknown): p is 'openai' | 'anthropic' | 'groq' | 'google' | 'gemini' =>\n  typeof p === 'string' && ['openai', 'anthropic', 'groq', 'google', 'gemini'].includes(p);","tryCatchPattern":"try {\n  model = new Mem0AITextGenerator(modelId, config, providerConfig);\n} catch (e) {\n  if ((e as Error).message === 'Invalid provider') {\n    throw new Error(`Provider '${config.provider}' passed the selector but is not wired; pin matching package versions`);\n  }\n  throw e;\n}","preventionTips":["Pin exact versions of mem0 integration and @ai-sdk packages so the selector list and dispatch switch cannot drift.","Add a startup smoke test that constructs the model for each configured provider.","If you extend supportedProviders in a fork, extend the switch in the same commit."],"tags":["provider-config","dispatch","version-skew"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}