mastra-ai/mastra · warning · InvalidArgumentError
Choose a valid value: ${EDITOR.join(', ')}
Error message
Choose a valid value: ${EDITOR.join(', ')} What it means
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.
Source
Thrown at packages/cli/src/commands/utils.ts:63
return 'npm'; // Default fallback
}
/**
* Wrap an async commander action so failures print a clean error message
* (never a stack trace) and exit non-zero.
*/
export function wrapAction(fn: (...args: any[]) => Promise<void>): (...args: any[]) => void {
return (...args: any[]) => {
fn(...args).catch((err: Error) => {
console.error(`Error: ${err.message}`);
process.exit(1);
});
};
}
export function parseMcp(value: string) {
if (!isValidEditor(value)) {
throw new InvalidArgumentError(`Choose a valid value: ${EDITOR.join(', ')}`);
}
return value;
}
export function parseSkills(value: string) {
// Skills flag accepts comma-separated agent names
return value
.split(',')
.map(s => s.trim())
.filter(Boolean);
}
export function parseComponents(value: string) {
const parsedValue = value.split(',');
if (!areValidComponents(parsedValue)) {
throw new InvalidArgumentError(`Choose valid components: ${COMPONENTS.join(', ')}`);
}View on GitHub (pinned to 75dd419e61)
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
Example fix
// before mastra init --mcp notepad // error: Choose a valid value: cursor, vscode, ... // after mastra init --mcp vscode
Defensive patterns
Strategy: validation
Validate before calling
const EDITORS = ['cursor', 'vscode'] as const;
type Editor = (typeof EDITORS)[number];
function parseEditorArg(v: string): Editor {
if (!(EDITORS as readonly string[]).includes(v)) {
throw new Error(`Choose a valid value: ${EDITORS.join(', ')}`);
}
return v as Editor;
} Type guard
function isValidEditor(v: string): v is Editor {
return (EDITORS as readonly string[]).includes(v);
} Try / catch
try {
program.parseAsync(process.argv);
} catch (e) {
if (e instanceof InvalidArgumentError && e.message.startsWith('Choose a valid value:')) {
console.error(`${e.message}\nSee --help for supported editors.`);
process.exitCode = 2;
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Choose valid components: ${COMPONENTS.join(', ')}
- Invalid --region "${region}". Expected one of: eu, us.
- MISSING_ARGUMENT
- Directory not found: ${dirArg}.${hint}
- Choose a valid provider: ${LLMProvider.join(', ')}
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/7725fd0554be1326.
Report an issue: GitHub.