{"record":{"id":"1993b965af29f8c5","repo":"elastic/elasticsearch","slug":"64-1993b9","errorCode":"64","errorMessage":"Must supply at least one setting to remove","messagePattern":"Must supply at least one setting to remove","errorType":"exception","errorClass":"UserException","httpStatus":null,"severity":"error","filePath":"distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/RemoveSettingKeyStoreCommand.java","lineNumber":39,"sourceCode":"import java.util.List;\n\n/**\n * A subcommand for the keystore cli to remove a setting.\n */\nclass RemoveSettingKeyStoreCommand extends BaseKeyStoreCommand {\n\n    private final OptionSpec<String> arguments;\n\n    RemoveSettingKeyStoreCommand() {\n        super(\"Remove settings from the keystore\", true);\n        arguments = parser.nonOptions(\"setting names\");\n    }\n\n    @Override\n    protected void executeCommand(Terminal terminal, OptionSet options, Environment env) throws Exception {\n        List<String> settings = arguments.values(options);\n        if (settings.isEmpty()) {\n            throw new UserException(ExitCodes.USAGE, \"Must supply at least one setting to remove\");\n        }\n        final KeyStoreWrapper keyStore = getKeyStore();\n        for (String setting : arguments.values(options)) {\n            if (keyStore.getSettingNames().contains(setting) == false) {\n                throw new UserException(ExitCodes.CONFIG, \"Setting [\" + setting + \"] does not exist in the keystore.\");\n            }\n            keyStore.remove(setting);\n        }\n        keyStore.save(env.configDir(), getKeyStorePassword().getChars());\n    }\n}\n","sourceCodeStart":21,"sourceCodeEnd":51,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/RemoveSettingKeyStoreCommand.java#L21-L51","documentation":"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.","triggerScenarios":"Running `bin/elasticsearch-keystore remove` with no arguments; a script whose setting list resolved to empty.","commonSituations":"Operators iterating a list to delete settings where the list is empty; accidental bare invocation.","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."],"exampleFix":"// before\nbin/elasticsearch-keystore remove\n// after\nbin/elasticsearch-keystore remove my.setting","handlingStrategy":"validation","validationCode":"if (settings == null || settings.isEmpty()) {\n    throw new IllegalArgumentException(\"at least one setting name required for remove\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use list to enumerate names before remove.","In cleanup scripts, only invoke remove when the name list is non-empty."],"tags":["elasticsearch","keystore-cli","cli-usage","argument-validation"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}