{"record":{"id":"15de944c37894b5d","repo":"apache/pulsar","slug":"invalid-key-value-pair-property-valid-format","errorCode":null,"errorMessage":"Invalid key value pair '${property}', valid format like 'a=b'.","messagePattern":"Invalid key value pair '(.+?)', valid format like 'a=b'\\.","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdBase.java","lineNumber":89,"sourceCode":"            Thread.currentThread().interrupt();\n            throw new PulsarAdminException(e);\n        } catch (TimeoutException e) {\n            throw new PulsarAdminException.TimeoutException(e);\n        } catch (ExecutionException e) {\n            throw PulsarAdminException.wrap(getApiException(e.getCause()));\n        } catch (Exception e) {\n            throw PulsarAdminException.wrap(getApiException(e));\n        }\n    }\n\n    Map<String, String> parseListKeyValueMap(List<String> metadata) {\n        Map<String, String> map = null;\n        if (metadata != null && !metadata.isEmpty()) {\n            map = new HashMap<>();\n            for (String property : metadata) {\n                int pos = property.indexOf('=');\n                if (pos <= 0) {\n                    throw new ParameterException(String.format(\"Invalid key value pair '%s', \"\n                            + \"valid format like 'a=b'.\", property));\n                }\n                map.put(property.substring(0, pos), property.substring(pos + 1));\n            }\n        }\n        return map;\n    }\n\n    // Used to register the subcomand.\n    protected CommandLine getCommander() {\n        return commander;\n    }\n\n    protected void addCommand(String name, Object cmd) {\n        commander.addSubcommand(name, cmd);\n    }\n\n    protected void addCommand(String name, Object cmd, String... aliases) {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdBase.java#L71-L107","documentation":"CmdBase.parseListKeyValueMap parses options that accept repeated key=value entries (e.g. --metadata or bookkeeper enrichment pairs). Each entry must contain an '=' at position > 0 so both a non-empty key and a value exist; otherwise a ParameterException is thrown. This rejects malformed property strings before they reach the broker.","triggerScenarios":"Passing values like 'key' (no '='), '=value' (empty key, '=' at index 0), or whitespace-mangled entries to options parsed by parseListKeyValueMap, such as cluster/topic metadata options.","commonSituations":"Forgetting the value ('--metadata enabled'), quoting issues where shells strip the '=', or copying formats from other tools that use 'key value' or 'key:value'.","solutions":["Format each entry as key=value with a non-empty key, e.g. --metadata a=b.","Quote entries in the shell so '=' is not stripped: --metadata \"a=b\".","To set an empty value, keep the '=' but note the key must be non-empty: a=.","Use key:value style only if the specific option documents it; this parser requires '='."],"exampleFix":"// before\npulsar-admin clusters create c1 --metadata myLabel\n// after\npulsar-admin clusters create c1 --metadata myLabel=true","handlingStrategy":"validation","validationCode":"for (String kv : metadata) {\n    int pos = kv.indexOf('=');\n    if (pos <= 0) {\n        throw new IllegalArgumentException(\"Entry '\" + kv + \"' must be in key=value form with a non-empty key\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    cmd.parseArgs(args);\n} catch (ParameterException e) {\n    System.err.println(\"Bad --metadata entry: use key=value, e.g. a=b. \" + e.getMessage());\n}","preventionTips":["Always include '=' and a non-empty key in every --metadata entry.","Quote key=value arguments in shells to avoid '=' or glob stripping.","Split key and value in scripts as arrays rather than hand-concatenating strings."],"tags":["cli","validation","argument-parsing","pulsar-admin"],"backgroundTag":"invalid-argument-format","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}