spring-projects/spring-boot · error · NoSuchCommandException
'%1$s' is not a valid command. See 'help'.
Error message
'%1$s' is not a valid command. See 'help'.
What it means
Thrown by CommandRunner.run() when args[0] does not match any registered command. The runner calls findCommand(commandName); a null result means no command is registered under that name, so it throws NoSuchCommandException with the offending name. It is a CommandException surfaced to the CLI user.
Source
Thrown at cli/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java:217
}
return StringUtils.toStringArray(rtn);
}
/**
* Parse the arguments and run a suitable command.
* @param args the arguments
* @return the outcome of the command
* @throws Exception if the command fails
*/
protected ExitStatus run(String... args) throws Exception {
if (args.length == 0) {
throw new NoArgumentsException();
}
String commandName = args[0];
String[] commandArguments = Arrays.copyOfRange(args, 1, args.length);
Command command = findCommand(commandName);
if (command == null) {
throw new NoSuchCommandException(commandName);
}
beforeRun(command);
try {
return command.run(commandArguments);
}
finally {
afterRun(command);
}
}
/**
* Subclass hook called before a command is run.
* @param command the command about to run
*/
protected void beforeRun(Command command) {
}
/**View on GitHub (pinned to 270dfe353f)
Solutions
- Run 'spring help' to list every available command name
- Correct the spelling of the command you typed
- If the command comes from an extension, install or enable that extension first
- Check the CLI version matches the command name you expect
Example fix
// before $ spring buld // after $ spring build
Defensive patterns
Strategy: validation
Validate before calling
// Before invoking a command programmatically, confirm it is registered.
// For CLI use, run `spring help` and match the name exactly.
String name = args[0];
java.util.List<String> known = java.util.Arrays.asList(/* from `spring help` output */);
if (!known.contains(name)) {
System.err.println("Unknown command '" + name + "'. See: spring help");
return;
} Try / catch
// If invoking CommandRunner programmatically:
try {
runner.run(args);
} catch (org.springframework.boot.cli.command.NoSuchCommandException ex) {
System.err.println(ex.getMessage()); // already user-friendly
} Prevention
- Always quote and spell-check the command name
- Run 'spring help' first when unsure of available commands
- Pin the CLI version in CI so command names do not change unexpectedly
When it happens
Trigger: Invoking the spring CLI with an unknown first token, e.g. 'spring buld' (typo of 'build') or any name absent from the registered command set. The check fires before any command logic runs.
Common situations: Typo in a command name; expecting a command provided by an extension that is not installed/enabled; running a CLI version where the command was renamed or removed.
Related errors
- '%1$s' is not a valid command. See 'help'.
- Invalid service URL ({})
- No project type with id '{}' - check the service capabilitie
- No type found with build '{}' and format '{}' check the serv
- Invalid content received from server ({})
AI-assisted analysis of spring-projects/spring-boot@270dfe353f (2026-08-11).
Data as JSON: /api/errors/8c764115843f5491.
Report an issue: GitHub.