{"record":{"id":"c59da8ff9a420f04","repo":"elastic/elasticsearch","slug":"64","errorCode":"64","errorMessage":"Missing setting name","messagePattern":"Missing setting name","errorType":"error_code","errorClass":"UserException","httpStatus":null,"severity":"error","filePath":"distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/AddFileKeyStoreCommand.java","lineNumber":51,"sourceCode":"    private final OptionSpec<String> arguments;\n\n    AddFileKeyStoreCommand() {\n        super(\"Add a file setting to the keystore\", false);\n        this.forceOption = parser.acceptsAll(\n            Arrays.asList(\"f\", \"force\"),\n            \"Overwrite existing setting without prompting, creating keystore if necessary\"\n        );\n        // jopt simple has issue with multiple non options, so we just get one set of them here\n        // and convert to File when necessary\n        // see https://github.com/jopt-simple/jopt-simple/issues/103\n        this.arguments = parser.nonOptions(\"(setting path)+\");\n    }\n\n    @Override\n    protected void executeCommand(Terminal terminal, OptionSet options, Environment env) throws Exception {\n        final List<String> argumentValues = arguments.values(options);\n        if (argumentValues.size() == 0) {\n            throw new UserException(ExitCodes.USAGE, \"Missing setting name\");\n        }\n        if (argumentValues.size() % 2 != 0) {\n            throw new UserException(ExitCodes.USAGE, \"settings and filenames must come in pairs\");\n        }\n\n        final KeyStoreWrapper keyStore = getKeyStore();\n\n        for (int i = 0; i < argumentValues.size(); i += 2) {\n            final String setting = argumentValues.get(i);\n\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.\");\n                    return;\n                }\n            }\n\n            final Path file = getPath(argumentValues.get(i + 1));","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/AddFileKeyStoreCommand.java#L33-L69","documentation":"Thrown by the `elasticsearch-keystore add-file` command when zero positional arguments are supplied. The command expects alternating setting-name / file-path pairs, so a completely empty argument list is rejected up front with a POSIX USAGE (64) exit code. It is a pure client-side argument validation check inside executeCommand before any keystore is opened.","triggerScenarios":"Running `bin/elasticsearch-keystore add-file` with no further tokens; invoking InstallPluginAction-style command wiring that calls AddFileKeyStoreCommand with an empty OptionSet; a wrapper script that forwards a positional list which resolved to nothing.","commonSituations":"Operators forgetting the required setting and path arguments; misconfigured automation/Ansible that passes an empty variable (e.g. `add-file {{ item }}` with item undefined); shell quoting that swallowed the arguments.","solutions":["Supply at least one setting/path pair on the command line: `bin/elasticsearch-keystore add-file my.setting /path/to/file`.","If scripting, assert the variable is non-empty before invoking: `[ -n \"$SETTING\" ] && bin/elasticsearch-keystore add-file \"$SETTING\" \"$FILE\"`.","Check `add-file --help` to confirm the expected `(setting path)+` non-option syntax."],"exampleFix":"// before\nbin/elasticsearch-keystore add-file\n// after\nbin/elasticsearch-keystore add-file my.setting /etc/es/ssl.key","handlingStrategy":"validation","validationCode":"// CLI: validate args before invoking the keystore tool\nif (args.isEmpty()) {\n    throw new IllegalArgumentException(\"add-file requires at least one (setting path) pair\");\n}\nif (args.size() % 2 != 0) {\n    throw new IllegalArgumentException(\"add-file requires setting/path pairs\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In scripts, assert positional args are non-empty before calling add-file.","Document the (setting path)+ syntax next to every add-file invocation in runbooks."],"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"}