{"record":{"id":"1ec0bdb6e1eed00d","repo":"mastra-ai/mastra","slug":"choose-a-valid-provider-llmprovider-join","errorCode":null,"errorMessage":"Choose a valid provider: ${LLMProvider.join(', ')}","messagePattern":"Choose a valid provider: (.+?)","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/utils.ts","lineNumber":88,"sourceCode":"  return value\n    .split(',')\n    .map(s => s.trim())\n    .filter(Boolean);\n}\n\nexport function parseComponents(value: string) {\n  const parsedValue = value.split(',');\n\n  if (!areValidComponents(parsedValue)) {\n    throw new InvalidArgumentError(`Choose valid components: ${COMPONENTS.join(', ')}`);\n  }\n\n  return parsedValue;\n}\n\nexport function parseLlmProvider(value: string) {\n  if (!isValidLLMProvider(value)) {\n    throw new InvalidArgumentError(`Choose a valid provider: ${LLMProvider.join(', ')}`);\n  }\n  return value;\n}\n\nexport function shouldSkipDotenvLoading(): boolean {\n  return process.env.MASTRA_SKIP_DOTENV === 'true' || process.env.MASTRA_SKIP_DOTENV === '1';\n}\n\n/**\n * Get the version tag (e.g., 'beta', 'latest') for the currently running mastra CLI.\n * Create passes its known version to avoid resolving package metadata from an installed layout.\n * Init omits it and preserves the existing best-effort undefined fallback.\n */\nexport async function getVersionTag(version?: string): Promise<string | undefined> {\n  try {\n    let currentVersion = version;\n    if (!currentVersion) {\n      const pkgPath = fileURLToPath(import.meta.resolve('mastra/package.json'));","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/utils.ts#L70-L106","documentation":"The Mastra CLI throws this when the value passed for the LLM provider option is not one of the supported providers in the LLMProvider list. parseLlmProvider validates the raw string before the CLI uses it to scaffold model configuration. Like parseComponents it raises commander's InvalidArgumentError so the help text is shown.","triggerScenarios":"Running `mastra init`/`mastra create` with --provider (or equivalent llm provider option) set to a string not in LLMProvider, e.g. 'openai' vs 'OpenAI' casing mismatch or a provider the CLI version doesn't support.","commonSituations":"Using a newer provider name with an older CLI version; case-sensitivity mistakes ('OpenAI' vs 'openai'); copy-pasting flags from tutorials for a different tool; typos like 'anthropicc'.","solutions":["Use one of the providers listed verbatim in the error message","Check `mastra init --help` (or the command's help) for the exact accepted provider strings","Upgrade the Mastra CLI (`pnpm dlx mastra@latest init`) if you need a recently added provider","Fix casing/typos to match the enum exactly"],"exampleFix":"// before\nmastra init --provider OpenAI\n// after\nmastra init --provider openai","handlingStrategy":"validation","validationCode":"const LLMProvider = ['openai', 'anthropic', 'groq', 'google', 'mistral'] as const;\nconst provider = 'openai';\nif (!LLMProvider.includes(provider as typeof LLMProvider[number])) {\n  throw new Error(`Invalid provider \"${provider}\". Valid: ${LLMProvider.join(', ')}`);\n}","typeGuard":"const isValidProvider = (v: string): v is LLMProvider => LLMProvider.includes(v as LLMProvider);","tryCatchPattern":"try {\n  runCli(['init', '--provider', provider]);\n} catch (e) {\n  if (e instanceof InvalidArgumentError && e.message.startsWith('Choose a valid provider')) {\n    console.error(`Unknown provider \"${provider}\". Supported: ${LLMProvider.join(', ')}`);\n  } else throw e;\n}","preventionTips":["Copy provider names exactly from CLI --help or the error message","Normalize casing (toLowerCase) before validating user input","Pin/upgrade CLI version so the supported provider list matches your expectations","Test CLI invocations in scripts with --dry-run style checks when available"],"tags":["cli","argument-validation","llm-provider"],"backgroundTag":"invalid-cli-argument","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}