{"record":{"id":"fb56c4df7d4b536f","repo":"mastra-ai/mastra","slug":"choose-valid-components-components-join","errorCode":null,"errorMessage":"Choose valid components: ${COMPONENTS.join(', ')}","messagePattern":"Choose valid components: (.+?)","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/utils.ts","lineNumber":80,"sourceCode":"  if (!isValidEditor(value)) {\n    throw new InvalidArgumentError(`Choose a valid value: ${EDITOR.join(', ')}`);\n  }\n  return value;\n}\n\nexport function parseSkills(value: string) {\n  // Skills flag accepts comma-separated agent names\n  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.","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/utils.ts#L62-L98","documentation":"The Mastra CLI throws this error when a --components flag value cannot be parsed into a valid list of components. parseComponents splits the comma-separated value and validates each entry against the known COMPONENTS list before proceeding with scaffolding. It uses commander's InvalidArgumentError so the CLI prints usage help alongside the message.","triggerScenarios":"Running `mastra init`/`mastra create` (or any command wiring this option) with --components set to a value not in COMPONENTS, a typo (e.g. 'agents ' with a stray space is fine after split? no — split keeps spaces, so ' agents' fails), an unsupported component name, or a value like 'agent' instead of 'agents'.","commonSituations":"Typing component names from memory instead of from docs; copying flags from older blog posts where component names changed; including whitespace around commas (split(',') keeps leading/trailing spaces, failing validation); passing plural/singular variants.","solutions":["List valid components from the error message and use exactly those spellings, e.g. --components agents,tools,workflows","Remove surrounding whitespace: write --components agents,tools not --components 'agents, tools'","Run the command with only the components you need or omit the flag to use defaults","Check `mastra init --help` for the current accepted component list"],"exampleFix":"// before\nmastra init --components agent,tool\n// after\nmastra init --components agents,tools","handlingStrategy":"validation","validationCode":"const COMPONENTS = ['agents', 'tools', 'workflows', 'networks', 'processors'];\nconst requested = 'agents,tools'.split(',').map(s => s.trim());\nconst invalid = requested.filter(c => !COMPONENTS.includes(c));\nif (invalid.length) throw new Error(`Invalid components: ${invalid.join(', ')}. Valid: ${COMPONENTS.join(', ')}`);","typeGuard":"const isComponent = (v: string): v is Component => COMPONENTS.includes(v as Component);","tryCatchPattern":"try {\n  runCli(['init', '--components', value]);\n} catch (e) {\n  if (e instanceof InvalidArgumentError && e.message.startsWith('Choose valid components')) {\n    console.error(`Bad --components value \"${value}\". Use: ${COMPONENTS.join(', ')}`);\n  } else throw e;\n}","preventionTips":["Trim each segment after splitting on commas before validating","Keep a single source-of-truth list of valid component names shared by CLI and docs","Validate flags in CI before running interactive/long CLI commands","Prefer `--help` output over remembered flag values"],"tags":["cli","argument-validation","commander"],"backgroundTag":"invalid-cli-argument","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}