{"record":{"id":"5e0454432b8d779b","repo":"elastic/elasticsearch","slug":"64-5e0454","errorCode":"64","errorMessage":"Must provide a single setting name to show","messagePattern":"Must provide a single setting name to show","errorType":"exception","errorClass":"UserException","httpStatus":null,"severity":"error","filePath":"distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/ShowKeyStoreCommand.java","lineNumber":47,"sourceCode":"import java.util.List;\n\n/**\n * A subcommand for the keystore cli to show the value of a setting in the keystore.\n */\npublic class ShowKeyStoreCommand extends BaseKeyStoreCommand {\n\n    private final OptionSpec<String> arguments;\n\n    public ShowKeyStoreCommand() {\n        super(\"Show a value from the keystore\", true);\n        this.arguments = parser.nonOptions(\"setting name\");\n    }\n\n    @Override\n    protected void executeCommand(Terminal terminal, OptionSet options, Environment env) throws Exception {\n        final List<String> names = arguments.values(options);\n        if (names.size() != 1) {\n            throw new UserException(ExitCodes.USAGE, \"Must provide a single setting name to show\");\n        }\n        final String settingName = names.get(0);\n\n        final KeyStoreWrapper keyStore = getKeyStore();\n        if (keyStore.getSettingNames().contains(settingName) == false) {\n            throw new UserException(ExitCodes.CONFIG, \"Setting [\" + settingName + \"] does not exist in the keystore.\");\n        }\n\n        try (InputStream input = keyStore.getFile(settingName)) {\n            final BytesReference bytes = org.elasticsearch.common.io.Streams.readFully(input);\n            try {\n                byte[] array = BytesReference.toBytes(bytes);\n                CharBuffer text = StandardCharsets.UTF_8.newDecoder()\n                    .onMalformedInput(CodingErrorAction.REPORT)\n                    .onUnmappableCharacter(CodingErrorAction.REPORT)\n                    .decode(ByteBuffer.wrap(array));\n\n                // This is not strictly true, but it's the best heuristic we have.","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/ShowKeyStoreCommand.java#L29-L65","documentation":"Thrown by `elasticsearch-keystore show` when the number of positional arguments is not exactly one. Exits USAGE (64). `show` is single-valued by design — it prints exactly one setting's value — so zero or 2+ names are both rejected before the keystore is consulted.","triggerScenarios":"Running `show` with no name; passing several names expecting bulk output; a script that always appends a name even when none applies.","commonSituations":"Operators used to `list` trying to dump multiple values; automation that did not validate count.","solutions":["Pass exactly one setting name: `bin/elasticsearch-keystore show my.setting`.","For multiple values, call `show` once per name, or use `list` plus `show` in a loop.","Validate `names.size() == 1` in calling code before invoking."],"exampleFix":"// before\nbin/elasticsearch-keystore show s1 s2\n// after\nbin/elasticsearch-keystore show s1 && bin/elasticsearch-keystore show s2","handlingStrategy":"validation","validationCode":"if (names == null || names.size() != 1) {\n    throw new IllegalArgumentException(\"show requires exactly one setting name\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate name count == 1 before invoking show.","Loop over names calling show once each for multiple values."],"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"}