{"record":{"id":"1478315316dd4ce6","repo":"elastic/elasticsearch","slug":"65","errorCode":"65","errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","errorClass":"UserException","httpStatus":null,"severity":"error","filePath":"distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/AddStringKeyStoreCommand.java","lineNumber":74,"sourceCode":"                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.\");\n                    return;\n                }\n            }\n\n            try {\n                keyStore.setString(setting, valueSupplier.apply(setting));\n            } catch (final IllegalArgumentException e) {\n                throw new UserException(ExitCodes.DATA_ERROR, e.getMessage());\n            }\n        }\n\n        keyStore.save(env.configDir(), getKeyStorePassword().getChars());\n    }\n\n}\n","sourceCodeStart":56,"sourceCodeEnd":82,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/AddStringKeyStoreCommand.java#L56-L82","documentation":"A generic `{}` placeholder UserException (DATA_ERROR 65) thrown by `add-string` when `keyStore.setString(setting, value)` throws an IllegalArgumentException. That IllegalArgumentException comes from `KeyStoreWrapper.validateSettingName`, which requires names to match `[A-Za-z0-9_\\-.]+`. So this error effectively means the setting name failed the allowed-character/pattern check, surfaced via the original exception's message.","triggerScenarios":"Passing a setting name containing spaces, slashes, colons, or other invalid characters (e.g. `add-string 'my setting'`); names with shell special chars that survive quoting; copy-pasting a setting key from a different system's namespace.","commonSituations":"Operators using a setting name that does not correspond to a real Elasticsearch setting key; unicode or whitespace accidentally included; confusable characters.","solutions":["Restrict the setting name to `[A-Za-z0-9_\\-.]+` — only letters, digits, underscore, hyphen, and dot.","Trim/normalize the name in scripts: `name=${name//[^A-Za-z0-9_.-]/_}`.","Check the official setting name in the Elasticsearch docs for the version you target."],"exampleFix":"// before\nbin/elasticsearch-keystore add-string 'my setting'\n// after\nbin/elasticsearch-keystore add-string my_setting","handlingStrategy":"validation","validationCode":"import java.util.regex.Pattern;\nprivate static final Pattern ALLOWED = Pattern.compile(\"[A-Za-z0-9_\\\\-.]+\");\n\nstatic String validateSettingName(String name) {\n    if (name == null || !ALLOWED.matcher(name).matches()) {\n        throw new IllegalArgumentException(\"Invalid setting name: \" + name);\n    }\n    return name;\n}","typeGuard":null,"tryCatchPattern":"try {\n    keyStore.setString(setting, value);\n} catch (IllegalArgumentException e) {\n    // surface a clear message; the name violated the allowed pattern\n    throw new IllegalArgumentException(\"Setting name '\" + setting + \"' must match [A-Za-z0-9_.-]+\", e);\n}","preventionTips":["Restrict setting names to letters, digits, underscore, hyphen, dot.","Trim whitespace before passing names; avoid copy-paste that introduces spaces."],"tags":["elasticsearch","keystore-cli","validation","setting-name"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}