{"record":{"id":"1796f7801e8fa31a","repo":"apache/pulsar","slug":"required-at-least-one-property-for-the-namespace","errorCode":null,"errorMessage":"Required at least one property for the namespace, but found %d.","messagePattern":"Required at least one property for the namespace, but found (.+?)\\.","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java","lineNumber":2478,"sourceCode":"            getAdmin().namespaces().setProperty(namespace, key, value);\n        }\n    }\n\n    @Command(description = \"Set properties of a namespace\")\n    private class SetPropertiesForNamespace extends CliCommand {\n\n        @Parameters(description = \"tenant/namespace\", arity = \"1\")\n        private String namespaceName;\n\n        @Option(names = {\"--properties\", \"-p\"}, description = \"key value pair properties(a=a,b=b,c=c)\",\n                required = true)\n        private java.util.List<String> properties;\n\n        @Override\n        void run() throws Exception {\n            String namespace = validateNamespace(namespaceName);\n            if (properties.size() == 0) {\n                throw new ParameterException(String.format(\"Required at least one property for the namespace, \"\n                        + \"but found %d.\", properties.size()));\n            }\n            Map<String, String> map = parseListKeyValueMap(properties);\n            getAdmin().namespaces().setProperties(namespace, map);\n        }\n    }\n\n    @Command(description = \"Get property for a namespace\")\n    private class GetPropertyForNamespace extends CliCommand {\n\n        @Parameters(description = \"tenant/namespace\", arity = \"1\")\n        private String namespaceName;\n\n        @Option(names = {\"--key\", \"-k\"}, description = \"Key of the property\", required = true)\n        private String key;\n\n        @Override\n        void run() throws Exception {","sourceCodeStart":2460,"sourceCodeEnd":2496,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java#L2460-L2496","documentation":"When setting the properties map of a namespace via `pulsar-admin namespaces set-properties`, the CLI requires at least one key=value entry. An empty list would wipe the properties map, which the CLI guards against by throwing a ParameterException.","triggerScenarios":"Running `pulsar-admin namespaces set-properties <namespace>` with no --properties values, or with an empty string value so the parsed list has size 0.","commonSituations":"Shell variable holding properties is empty/unset; quoting issue causes the argument to vanish; scripting that loops over properties that happen to be empty.","solutions":["Provide at least one key=value pair, e.g. --properties env=prod team=data","If the goal is to clear all properties, use the dedicated delete/unset path (remove properties individually) rather than passing an empty list","Fix shell quoting so the key=value list actually reaches the CLI"],"exampleFix":"// before\npulsar-admin namespaces set-properties my-tenant/my-ns --properties \"\"\n// after\npulsar-admin namespaces set-properties my-tenant/my-ns --properties env=prod --properties team=data","handlingStrategy":"validation","validationCode":"if (properties == null || properties.isEmpty()) {\n    throw new IllegalArgumentException(\"At least one key=value property is required\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    admin.namespaces().setProperties(namespace, map);\n} catch (org.apache.pulsar.client.admin.PulsarAdminException e) {\n    // handle invalid/empty properties\n}","preventionTips":["Validate shell variables before building the CLI command","Ensure key=value quoting survives the shell","Never pass an empty properties list; remove properties individually instead"],"tags":["cli","validation","namespaces"],"backgroundTag":"missing-required-argument","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}