{"record":{"id":"7725fd0554be1326","repo":"mastra-ai/mastra","slug":"choose-a-valid-value-editor-join","errorCode":null,"errorMessage":"Choose a valid value: ${EDITOR.join(', ')}","messagePattern":"Choose a valid value: (.+?)","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"warning","filePath":"packages/cli/src/commands/utils.ts","lineNumber":63,"sourceCode":"  return 'npm'; // Default fallback\n}\n\n/**\n * Wrap an async commander action so failures print a clean error message\n * (never a stack trace) and exit non-zero.\n */\nexport function wrapAction(fn: (...args: any[]) => Promise<void>): (...args: any[]) => void {\n  return (...args: any[]) => {\n    fn(...args).catch((err: Error) => {\n      console.error(`Error: ${err.message}`);\n      process.exit(1);\n    });\n  };\n}\n\nexport function parseMcp(value: string) {\n  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  }","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/utils.ts#L45-L81","documentation":"parseMcp is a Commander flag parser for the --mcp/--editor style option. It validates the value against the known EDITOR list via isValidEditor and throws Commander's InvalidArgumentError listing the accepted editors when the value does not match, so Commander aborts with a usage error before the command runs.","triggerScenarios":"Passing an editor name not in the EDITOR constant to the option backed by parseMcp, e.g. `--mcp myeditor` or a wrongly-cased/duplicate value like `--mcp Visual Studio Code` instead of a listed slug.","commonSituations":"Users guessing editor identifiers not in the supported list; documentation drift where an editor was removed/renamed; shell autocomplete inserting an unsupported value; copying examples from older CLI versions.","solutions":["Use one of the listed values printed in the error message (the EDITOR list)","Check `mastra --help` for the exact accepted editor values and casing","If your editor is missing, open an issue/PR to add it to the EDITOR constant","Upgrade the CLI if a recently added editor is not recognized in your installed version"],"exampleFix":"// before\nmastra init --mcp notepad\n// error: Choose a valid value: cursor, vscode, ...\n// after\nmastra init --mcp vscode","handlingStrategy":"validation","validationCode":"const EDITORS = ['cursor', 'vscode'] as const;\ntype Editor = (typeof EDITORS)[number];\nfunction parseEditorArg(v: string): Editor {\n  if (!(EDITORS as readonly string[]).includes(v)) {\n    throw new Error(`Choose a valid value: ${EDITORS.join(', ')}`);\n  }\n  return v as Editor;\n}","typeGuard":"function isValidEditor(v: string): v is Editor {\n  return (EDITORS as readonly string[]).includes(v);\n}","tryCatchPattern":"try {\n  program.parseAsync(process.argv);\n} catch (e) {\n  if (e instanceof InvalidArgumentError && e.message.startsWith('Choose a valid value:')) {\n    console.error(`${e.message}\\nSee --help for supported editors.`);\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Copy accepted editor values from `mastra --help` rather than guessing","Use tab completion / exact slugs like vscode, cursor","Check the CHANGELOG when upgrading the CLI in case the editor list changed","Validate the flag value in wrapper scripts before invoking the CLI"],"tags":["cli","argument-validation","commander"],"backgroundTag":"invalid-argument-value","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}