apache/pulsar · error · IllegalArgumentException

ResourceGroupCreate: Invalid null ResourceGroup config

Error message

ResourceGroupCreate: Invalid null ResourceGroup config

What it means

ResourceGroupService's constructor validates create parameters via checkRGCreateParams and throws IllegalArgumentException if the ResourceGroup config object is null. A resource group cannot be created without its configuration (dispatch/subscribe rate limits), so null is rejected immediately.

Source

Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java:807

                calculateQuotaPeriodicTask = null;
            }
            log.info("Stopped ResourceGroupService periodic tasks because no registrations remain");
        }
    }

    private void initialize() {
        // Store the configured interval. Do not start periodic tasks unconditionally here.
        // Schedulers are started by maybeStartSchedulers() when the first tenant/namespace is registered.
        final long periodInSecs = pulsar.getConfiguration().getResourceUsageTransportPublishIntervalInSecs();
        this.aggregateLocalUsagePeriodInSeconds = this.resourceUsagePublishPeriodInSeconds = periodInSecs;
        // if any tenant/namespace registrations already exist, maybeStartSchedulers() will start the schedulers now.
        maybeStartSchedulers();
    }

    private void checkRGCreateParams(String rgName, org.apache.pulsar.common.policies.data.ResourceGroup rgConfig)
      throws PulsarAdminException {
        if (rgConfig == null) {
            throw new IllegalArgumentException("ResourceGroupCreate: Invalid null ResourceGroup config");
        }

        if (rgName.isEmpty()) {
            throw new IllegalArgumentException("ResourceGroupCreate: can't create resource group with an empty name");
        }

        ResourceGroup rg = getResourceGroupInternal(rgName);
        if (rg != null) {
            throw new PulsarAdminException("Resource group already exists:" + rgName);
        }
    }
    @Getter
    private final PulsarService pulsar;

    protected final ResourceQuotaCalculator quotaCalculator;
    private ResourceUsageTransportManager resourceUsageTransportManagerMgr;

    // rgConfigListener is used only through its side effects in the ctors, to set up RG/NS loading in config-listeners.

View on GitHub (pinned to 820761864e)

Solutions

  1. Supply a valid ResourceGroup config object with at least dispatch/subscribe rate limits set
  2. Check the REST request body is non-empty, valid JSON matching the ResourceGroup schema
  3. In client code, null-check the config before calling createResourceGroup
  4. Verify admin SDK version compatibility — malformed payloads may deserialize to null

Example fix

// before
admin.resourcegroups().createResourceGroup("rg1", null);
// after
ResourceGroup rg = new ResourceGroup();
rg.setDispatchRate(new DispatchRate());
rg.setSubscribeRate(new SubscribeRate());
admin.resourcegroups().createResourceGroup("rg1", rg);
Defensive patterns

Strategy: validation

Validate before calling

if (rgConfig == null) {
    throw new IllegalArgumentException("ResourceGroup config must be provided");
}

Type guard

boolean validRgConfig(ResourceGroup rg) {
    return rg != null && rg.getDispatchRate() != null;
}

Try / catch

try {
    createResourceGroupPath(name, config);
} catch (IllegalArgumentException e) {
    if (String.valueOf(e.getMessage()).contains("Invalid null ResourceGroup config")) {
        // fix request body and retry
    } else throw e;
}

Prevention

When it happens

Trigger: Passing a null ResourceGroup config to the resource-group creation path (admin createResourceGroup call that supplies no policy object), usually due to unmarshalled/empty request bodies.

Common situations: REST client sending an empty or malformed JSON body to the resourcegroups admin endpoint; SDK method invoked with null config; deserialization silently producing null.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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