{"record":{"id":"c841662ec8fcc6ba","repo":"apache/pulsar","slug":"the-broker-brokeraddress-is-not-among-the-assig","errorCode":null,"errorMessage":"The broker ${brokerAddress} is not among the assigned broker pools for the controlled namespace.","messagePattern":"The broker (.+?) is not among the assigned broker pools for the controlled namespace\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-common/src/main/java/org/apache/pulsar/common/policies/impl/NamespaceIsolationPolicies.java","lineNumber":148,"sourceCode":"    }\n\n    /**\n     * Get the broker assignment based on the namespace name.\n     *\n     * @param nsPolicy\n     *            The namespace name\n     * @param brokerAddress\n     *            The broker address is the format of host:port\n     * @return The broker assignment: {primary, secondary, shared}\n     */\n    private BrokerAssignment getBrokerAssignment(NamespaceIsolationPolicy nsPolicy, String brokerAddress) {\n        if (nsPolicy != null) {\n            if (nsPolicy.isPrimaryBroker(brokerAddress)) {\n                return BrokerAssignment.primary;\n            } else if (nsPolicy.isSecondaryBroker(brokerAddress)) {\n                return BrokerAssignment.secondary;\n            }\n            throw new IllegalArgumentException(\"The broker \" + brokerAddress\n                    + \" is not among the assigned broker pools for the controlled namespace.\");\n        }\n        // Only uncontrolled namespace will be assigned to the shared pool\n        if (!this.isSharedBroker(brokerAddress)) {\n            throw new IllegalArgumentException(\"The broker \" + brokerAddress\n                    + \" is not among the shared broker pools for the uncontrolled namespace.\");\n        }\n        return BrokerAssignment.shared;\n    }\n\n    public void assignBroker(NamespaceName nsname, BrokerStatus brkStatus, SortedSet<BrokerStatus> primaryCandidates,\n            SortedSet<BrokerStatus> secondaryCandidates, SortedSet<BrokerStatus> sharedCandidates) {\n        NamespaceIsolationPolicy nsPolicy = this.getPolicyByNamespace(nsname);\n        BrokerAssignment brokerAssignment = this.getBrokerAssignment(nsPolicy, brkStatus.getBrokerAddress());\n        if (brokerAssignment == BrokerAssignment.primary) {\n            // Only add to candidates if allowed by policy\n            if (nsPolicy != null && nsPolicy.isPrimaryBrokerAvailable(brkStatus)) {\n                primaryCandidates.add(brkStatus);","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-common/src/main/java/org/apache/pulsar/common/policies/impl/NamespaceIsolationPolicies.java#L130-L166","documentation":"NamespaceIsolationPolicies.getBrokerAssignment() classifies a broker as primary or secondary for a namespace whose namespace-isolation policy is defined. If the broker matches neither the policy's primary nor secondary broker regex lists, the broker is outside all assigned pools and the method throws IllegalArgumentException. This is a policy-configuration inconsistency, not a runtime failure of the broker.","triggerScenarios":"Calling brokerAssignment (or getBrokerAssignment) with a brokerAddress whose service URL matches no primary/secondary regex in the namespace's isolation policy, while a policy exists for that namespace (controlled namespace).","commonSituations":"A broker started with a service URL that doesn't match any configured regex (hostname vs FQDN vs IP mismatch), typo in the regex, or a new broker added without updating the isolation policy.","solutions":["Add the broker's service URL pattern to the policy's primary or secondary broker regex list in namespaceIsolationPolicies.json","Fix the broker's advertised service URL so it matches an existing regex (e.g. consistent FQDN)","Verify regexes with a quick test against the actual broker URL before deploying","Remove/recreate the isolation policy if the namespace should be uncontrolled"],"exampleFix":"// before (policy)\n\"primary\": [\"broker-1.*.cluster\"]   // broker URL is broker-5.us-west.example.com:6650 — no match\n// after\n\"primary\": [\"broker-[0-9]+\\\\.us-west\\\\.example\\\\.com.*\"],\n\"secondary\": [\"broker-[0-9]+\\\\.us-east\\\\.example\\\\.com.*\"]","handlingStrategy":"validation","validationCode":"// Check the broker matches primary or secondary regexes before classification\nboolean matches = policy != null &&\n    (policy.isPrimaryBroker(brokerUrl) || policy.isSecondaryBroker(brokerUrl));\nif (!matches) throw new IllegalStateException(\"Broker \" + brokerUrl + \" not in isolation policy pools\");","typeGuard":"static boolean brokerInPolicy(NamespaceIsolationPolicyImpl p, String url) {\n    return p != null && (p.isPrimaryBroker(url) || p.isSecondaryBroker(url));\n}","tryCatchPattern":"try {\n    BrokerAssignment a = policies.brokerAssignment(ns, brokerUrl);\n} catch (IllegalArgumentException e) {\n    log.warn(\"Broker {} not covered by isolation policy for {}: {}\", brokerUrl, ns, e.getMessage());\n    // treat as unassigned / alert, don't crash the selection loop\n}","preventionTips":["Keep broker service URLs consistent (FQDN) with isolation regexes","Test regexes against every broker hostname in CI before deploying policies","Add new brokers to policy regex lists as part of onboarding","Log all regexes and broker URLs when this error occurs"],"tags":["configuration","namespace-isolation","regex-mismatch"],"backgroundTag":"broker-not-in-isolation-policy","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"}