{"record":{"id":"86bf5414f555e7ca","repo":"elastic/elasticsearch","slug":"64-86bf54","errorCode":"64","errorMessage":"the setting names can not be empty","messagePattern":"the setting names can not be empty","errorType":"error_code","errorClass":"UserException","httpStatus":null,"severity":"error","filePath":"distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/AddStringKeyStoreCommand.java","lineNumber":48,"sourceCode":"\n    private final OptionSpec<Void> stdinOption;\n    private final OptionSpec<String> arguments;\n\n    AddStringKeyStoreCommand() {\n        super(\"Add string settings to the keystore\", false);\n        this.stdinOption = parser.acceptsAll(Arrays.asList(\"x\", \"stdin\"), \"Read setting values from stdin\");\n        this.forceOption = parser.acceptsAll(\n            Arrays.asList(\"f\", \"force\"),\n            \"Overwrite existing setting without prompting, creating keystore if necessary\"\n        );\n        this.arguments = parser.nonOptions(\"setting names\");\n    }\n\n    @Override\n    protected void executeCommand(Terminal terminal, OptionSet options, Environment env) throws Exception {\n        final List<String> settings = arguments.values(options);\n        if (settings.isEmpty()) {\n            throw new UserException(ExitCodes.USAGE, \"the setting names can not be empty\");\n        }\n\n        final KeyStoreWrapper keyStore = getKeyStore();\n\n        final CheckedFunction<String, char[], IOException> valueSupplier = s -> {\n            final String prompt;\n            if (options.has(stdinOption)) {\n                prompt = \"\";\n            } else {\n                prompt = \"Enter value for \" + s + \": \";\n            }\n            return terminal.readSecret(prompt);\n        };\n\n        for (final String setting : settings) {\n            if (keyStore.getSettingNames().contains(setting) && options.has(forceOption) == false) {\n                if (terminal.promptYesNo(\"Setting \" + setting + \" already exists. Overwrite?\", false) == false) {\n                    terminal.println(\"Exiting without modifying keystore.\");","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/AddStringKeyStoreCommand.java#L30-L66","documentation":"Thrown by `elasticsearch-keystore add-string` when no positional setting-name arguments are supplied. Like add-file it validates arguments up front with USAGE (64) before opening the keystore. Each supplied name will subsequently prompt for a secret value (or read from stdin with `-x`).","triggerScenarios":"Running `bin/elasticsearch-keystore add-string` bare; an automation template whose setting-name variable is empty; redirecting input expecting the names to come from stdin (they are positional, not stdin).","commonSituations":"Operators confusing `add-string` with `add-file` semantics; piping a setting name via stdin without `-x`/`--stdin` which only controls the value, not the name.","solutions":["Provide at least one setting name: `bin/elasticsearch-keystore add-string my.secret`.","To pipe values from stdin, still pass names positionally and add `-x`: `echo $VAL | bin/elasticsearch-keystore add-string -x my.secret`.","In scripts, guard with `[ \"$#\" -ge 1 ]` or equivalent before calling."],"exampleFix":"// before\nbin/elasticsearch-keystore add-string\n// after\nbin/elasticsearch-keystore add-string my.secret","handlingStrategy":"validation","validationCode":"if (settings == null || settings.isEmpty()) {\n    throw new IllegalArgumentException(\"at least one setting name required for add-string\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember setting names are positional, not read from stdin; only values use `-x`.","Guard `[ -n \"$NAME\" ]` in shell before calling."],"tags":["elasticsearch","keystore-cli","cli-usage","argument-validation"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}