elastic/elasticsearch · error · UserException

78

78

Error message

Setting [{}] does not exist in the keystore.

What it means

Thrown by `remove` when a requested setting name is not present in the loaded keystore's setting names. Exits CONFIG (78). It is a per-name check inside the loop; the first missing name aborts the whole operation before `keyStore.save` runs, so nothing is mutated.

Source

Thrown at distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/RemoveSettingKeyStoreCommand.java:44

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

  1. Run `bin/elasticsearch-keystore list` to confirm the exact name before removing.
  2. Make cleanup scripts idempotent by checking membership before calling remove.
  3. Watch for trailing whitespace or quoting differences in the name.

Example fix

// before
bin/elasticsearch-keystore remove mysetting
// after
bin/elasticsearch-keystore list   # confirm exact name
bin/elasticsearch-keystore remove my.setting
Defensive patterns

Strategy: validation

Validate before calling

Set<String> present = new HashSet<>(keyStore.getSettingNames());
for (String s : settings) {
    if (!present.contains(s)) {
        // skip or report, don't call remove
    }
}

Try / catch

try {
    removeSetting(name);
} catch (UserException e) {
    if (e.exitCode == ExitCodes.CONFIG) {
        // setting absent — idempotent no-op for cleanup scripts
    }
}

Prevention

When it happens

Trigger: Typo in the setting name; removing a setting that was already removed; referencing a name from a different node's keystore; case mismatch.

Common situations: Idempotent cleanup scripts that double-delete; copying a remove command from a different cluster.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/2b723cb88cbf3464. Report an issue: GitHub.