elastic/elasticsearch · error · UserException
64
64
Error message
Must supply at least one setting to remove
What it means
Thrown by `elasticsearch-keystore remove` when no positional setting names are given. Exits USAGE (64). The non-options spec declares `setting names`, so an empty list means nothing to remove and is rejected before opening the keystore for mutation.
Source
Thrown at distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/RemoveSettingKeyStoreCommand.java:39
import java.util.List;
/**
* A subcommand for the keystore cli to remove a setting.
*/
class RemoveSettingKeyStoreCommand extends BaseKeyStoreCommand {
private final OptionSpec<String> arguments;
RemoveSettingKeyStoreCommand() {
super("Remove settings from the keystore", true);
arguments = parser.nonOptions("setting names");
}
@Override
protected void executeCommand(Terminal terminal, OptionSet options, Environment env) throws Exception {
List<String> settings = arguments.values(options);
if (settings.isEmpty()) {
throw new UserException(ExitCodes.USAGE, "Must supply at least one setting to remove");
}
final KeyStoreWrapper keyStore = getKeyStore();
for (String setting : arguments.values(options)) {
if (keyStore.getSettingNames().contains(setting) == false) {
throw new UserException(ExitCodes.CONFIG, "Setting [" + setting + "] does not exist in the keystore.");
}
keyStore.remove(setting);
}
keyStore.save(env.configDir(), getKeyStorePassword().getChars());
}
}
View on GitHub (pinned to db6a809a66)
Solutions
- Pass one or more setting names: `bin/elasticsearch-keystore remove my.setting`.
- In scripts, guard: only call remove when the name list is non-empty.
- Use `list` first to confirm exact names to remove.
Example fix
// before bin/elasticsearch-keystore remove // after bin/elasticsearch-keystore remove my.setting
Defensive patterns
Strategy: validation
Validate before calling
if (settings == null || settings.isEmpty()) {
throw new IllegalArgumentException("at least one setting name required for remove");
} Prevention
- Use list to enumerate names before remove.
- In cleanup scripts, only invoke remove when the name list is non-empty.
When it happens
Trigger: Running `bin/elasticsearch-keystore remove` with no arguments; a script whose setting list resolved to empty.
Common situations: Operators iterating a list to delete settings where the list is empty; accidental bare invocation.
Related errors
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/1993b965af29f8c5.
Report an issue: GitHub.