{"record":{"id":"7f3a3aacab89b47f","repo":"apache/pulsar","slug":"invalid-number-of-bundles-number-of-bundles-has-t","errorCode":null,"errorMessage":"Invalid number of bundles. Number of bundles has to be in the range of (0, 2^32].","messagePattern":"Invalid number of bundles\\. Number of bundles has to be in the range of \\(0, 2\\^32\\]\\.","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java","lineNumber":163,"sourceCode":"    @Command(description = \"Creates a new namespace\")\n    private class Create extends CliCommand {\n        @Parameters(description = \"tenant/namespace\", arity = \"1\")\n        private String namespaceName;\n\n        @Option(names = { \"--clusters\", \"-c\" },\n                description = \"List of clusters this namespace will be assigned\", required = false, split = \",\")\n        private java.util.List<String> clusters;\n\n        @Option(names = { \"--bundles\", \"-b\" }, description = \"number of bundles to activate\", required = false)\n        private int numBundles = 0;\n\n        private static final long MAX_BUNDLES = ((long) 1) << 32;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String namespace = validateNamespace(namespaceName);\n            if (numBundles < 0 || numBundles > MAX_BUNDLES) {\n                throw new ParameterException(\n                        \"Invalid number of bundles. Number of bundles has to be in the range of (0, 2^32].\");\n            }\n\n            Policies policies = new Policies();\n            policies.bundles = numBundles > 0 ? BundlesData.builder()\n                    .numBundles(numBundles).build() : null;\n\n            if (clusters != null) {\n                policies.replication_clusters = new HashSet<>(clusters);\n            }\n\n            getAdmin().namespaces().createNamespace(namespace, policies);\n        }\n    }\n\n    @Command(description = \"Deletes a namespace.\")\n    private class Delete extends CliCommand {\n        @Parameters(description = \"tenant/namespace\", arity = \"1\")","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java#L145-L181","documentation":"Thrown by the set-message-ttl-style namespace command (set-number-of-bundles) when the supplied bundle count is negative or exceeds 2^32. Bundles define the namespace's partitioned range space; the broker schema allows (0, 2^32] and the CLI pre-validates before building Policies.","triggerScenarios":"Running `pulsar-admin namespaces set-number-of-bundles` (or equivalent) with --num-bundles given a negative number, a value above 4294967296, or a garbage/overflowed value parsed as an int/long.","commonSituations":"Passing -1 to mean 'unset'; scripting with arithmetic that produces 0 or negatives; confusing max bundles (2^32) with recommended values (usually powers of 2 up to a few thousand); copy-paste of a large sentinel number.","solutions":["Supply a positive bundle count in (0, 2^32], typically a power of two like 16, 64, or 256","Never pass negative or 0 intending 'default'; to clear bundles use the appropriate unset/delete API instead","Double-check the script computing numBundles for off-by-one or sign errors","Remember numBundles > 0 creates BundlesData; anything else is rejected here"],"exampleFix":"// before\npulsar-admin namespaces set-number-of-bundles my-tenant/ns --num-bundles -1\n// after\npulsar-admin namespaces set-number-of-bundles my-tenant/ns --num-bundles 64","handlingStrategy":"validation","validationCode":"MAX_BUNDLES=4294967296\nif (( NUM_BUNDLES <= 0 || NUM_BUNDLES > MAX_BUNDLES )); then echo \"numBundles must be in (0, 2^32]\"; exit 1; fi","typeGuard":null,"tryCatchPattern":"try { ... } catch (ParameterException e) { /* invalid bundle count: correct value, no retry */ }","preventionTips":["Use a positive bundle count, ideally a power of two (16/64/256)","Never send -1 or 0 to mean 'default'","Sanity-check any arithmetic that derives the count"],"tags":["cli","argument-validation","bundles","pulsar-admin"],"backgroundTag":"invalid-cli-arguments","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"}