{"record":{"id":"47cabc607e3388cc","repo":"apache/pulsar","slug":"destinationbroker-cannot-be-set-when-bundle-is","errorCode":null,"errorMessage":"--destinationBroker cannot be set when --bundle is not specified.","messagePattern":"--destinationBroker cannot be set when --bundle is not specified\\.","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java","lineNumber":898,"sourceCode":"        @Parameters(description = \"tenant/namespace\", arity = \"1\")\n        private String namespaceName;\n\n        @Option(names = { \"--bundle\", \"-b\" }, description = \"{start-boundary}_{end-boundary}\")\n        private String bundle;\n\n        @Option(names = { \"--destinationBroker\", \"-d\" },\n                description = \"Target brokerWebServiceAddress to which the bundle has to be allocated to. \"\n                        + \"--destinationBroker cannot be set when --bundle is not specified.\")\n        private String destinationBroker;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String namespace = validateNamespace(namespaceName);\n\n\n            if (bundle == null) {\n                if (StringUtils.isNotBlank(destinationBroker)) {\n                    throw new ParameterException(\"--destinationBroker cannot be set when --bundle is not specified.\");\n                }\n                getAdmin().namespaces().unload(namespace);\n            } else {\n                getAdmin().namespaces().unloadNamespaceBundle(namespace, bundle, destinationBroker);\n            }\n        }\n    }\n\n    @Command(description = \"Split a namespace-bundle from the current serving broker\")\n    private class SplitBundle extends CliCommand {\n        @Parameters(description = \"tenant/namespace\", arity = \"1\")\n        private String namespaceName;\n\n        @Option(names = { \"--bundle\",\n                \"-b\" }, description = \"{start-boundary}_{end-boundary} \"\n                        + \"(mutually exclusive with --bundle-type)\", required = false)\n        private String bundle;\n","sourceCodeStart":880,"sourceCodeEnd":916,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java#L880-L916","documentation":"The pulsar-admin 'unload namespace' command throws this ParameterException when --destinationBroker is supplied without --bundle. Unloading a whole namespace has no single destination broker (it covers all bundles), so a target broker only makes sense when unloading one specific bundle. The CLI rejects the contradictory combination before calling the admin API.","triggerScenarios":"Running `pulsar-admin namespaces unload <namespace> --destinationBroker <broker>` (or the equivalent CliCommand invocation with destinationBroker set and bundle == null). The run() method checks StringUtils.isNotBlank(destinationBroker) while bundle is null.","commonSituations":"Operators scripting namespace unload who copy the --destinationBroker flag from a bundle-unload example; automation templates that always append --destinationBroker regardless of whether a bundle was selected.","solutions":["Add a --bundle <bundle-range> argument to the command, or","Remove the --destinationBroker flag when unloading the entire namespace (use plain `unload <namespace>`), or","If the goal is to move a specific bundle, invoke `unload --bundle <bundle> --destinationBroker <broker>`"],"exampleFix":"// before\npulsar-admin namespaces unload my-tenant/my-ns --destinationBroker broker-3:6650\n// after\npulsar-admin namespaces unload my-tenant/my-ns --bundle '0x00000000_0xffffffff' --destinationBroker broker-3:6650","handlingStrategy":"validation","validationCode":"// shell guard before invoking the CLI\nif [ -n \"$DEST_BROKER\" ] && [ -z \"$BUNDLE\" ]; then\n  echo \"--destinationBroker requires --bundle\" >&2; exit 1;\nfi\npulsar-admin namespaces unload \"$NS\" ${BUNDLE:+--bundle \"$BUNDLE\"} ${DEST_BROKER:+--destinationBroker \"$DEST_BROKER\"}","typeGuard":"// pseudo: reject the invalid combination before dispatch\nboolean invalid = (destinationBroker != null && !destinationBroker.isBlank()) && (bundle == null);\nif (invalid) throw new IllegalArgumentException(\"--destinationBroker requires --bundle\");","tryCatchPattern":"try {\n    admin.namespaces().unload(ns);\n} catch (IllegalArgumentException e) {\n    // log the flag misuse and correct the command arguments\n}","preventionTips":["Only pass --destinationBroker together with --bundle","Use plain `unload <ns>` for whole-namespace unloads","Validate CLI argument combinations in wrapper scripts"],"tags":["cli","parameter-validation","pulsar-admin","namespaces"],"backgroundTag":"mutually-exclusive-cli-flags","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"}