apache/pulsar · error · ParameterException

unable to parse primary parameter list:

Error message

unable to parse primary parameter list: 

What it means

Thrown by createNamespaceIsolationData when the --primary option parses to an empty list. Note the message bug: it appends `namespaces` instead of `primary`. A namespace isolation policy must designate at least one primary broker regex, so empty input is rejected as a JCommander ParameterException before contacting the broker.

Source

Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaceIsolationPolicy.java:191

                .collect(Collectors.toList());
    }

    private NamespaceIsolationData createNamespaceIsolationData(List<String> namespaces,
                                                                List<String> primary,
                                                                List<String> secondary,
                                                                String autoFailoverPolicyTypeName,
                                                                Map<String, String> autoFailoverPolicyParams,
                                                                NamespaceIsolationPolicyUnloadScope unload) {

        // validate
        namespaces = validateList(namespaces);
        if (namespaces.isEmpty()) {
            throw new ParameterException("unable to parse namespaces parameter list: " + namespaces);
        }

        primary = validateList(primary);
        if (primary.isEmpty()) {
            throw new ParameterException("unable to parse primary parameter list: " + namespaces);
        }

        secondary = validateList(secondary);

        // System.out.println("namespaces = " + namespaces);
        // System.out.println("primary = " + primary);
        // System.out.println("secondary = " + secondary);
        // System.out.println("autoFailoverPolicyTypeName = " + autoFailoverPolicyTypeName);
        // System.out.println("autoFailoverPolicyParams = " + autoFailoverPolicyParams);

        NamespaceIsolationData.Builder nsIsolationDataBuilder = NamespaceIsolationData.builder();

        if (namespaces != null) {
            nsIsolationDataBuilder.namespaces(namespaces);
        }

        if (primary != null) {
            nsIsolationDataBuilder.primary(primary);

View on GitHub (pinned to 820761864e)

Solutions

  1. Pass at least one primary broker regex, e.g. --primary 'broker-rack1.*'
  2. Quote the regex so the shell does not expand bracket/glob characters to nothing: --primary 'my-cluster-broker[0-9]+'
  3. Verify the shell variable holding the primary list is populated
  4. If multiple primaries are needed use a comma-separated list

Example fix

// before
pulsar-admin ns-isolation-policy create p1 --namespaces 't/ns.*' --primary '' ...
// after
pulsar-admin ns-isolation-policy create p1 --namespaces 't/ns.*' --primary 'broker-rack1[0-9]*' ...
Defensive patterns

Strategy: validation

Validate before calling

if [ -z "$PRIMARY_REGEX" ]; then echo "--primary must contain at least one broker regex" >&2; exit 1; fi

Try / catch

try { createNamespaceIsolationData(...); } catch (ParameterException e) { /* invalid input; fix args, no retry */ }

Prevention

When it happens

Trigger: Running `pulsar-admin namespaces-isolation-policy create` with --primary omitted or supplied as empty string / only commas, after --namespaces already passed validation.

Common situations: Forgetting the --primary flag because it seems optional; shell variable holding the primary regex list is empty; quoting strips the regex (special characters like [ ] interpreted by shell) leaving an empty value.

Understand the failure class

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/bf952792881db78d. Report an issue: GitHub.