apache/pulsar · error · IllegalArgumentException

ResourceGroupCreate: can't create resource group with an emp

Error message

ResourceGroupCreate: can't create resource group with an empty name

What it means

ResourceGroupService rejects creation of a resource group whose name is the empty string, throwing IllegalArgumentException from checkRGCreateParams. Names are used as map keys and in admin paths, so an empty name is invalid.

Source

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

    }

    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.
    private final ResourceGroupConfigListener rgConfigListener;

    // Given a RG-name, get the resource-group
    private ConcurrentHashMap<String, ResourceGroup> resourceGroupsMap = new ConcurrentHashMap<>();

View on GitHub (pinned to 820761864e)

Solutions

  1. Provide a non-empty resource group name in the create call
  2. Fix the script/template so the name variable is populated
  3. Ensure the REST URL includes the group name path segment
  4. Add client-side validation rejecting empty names before calling the API

Example fix

// before
String name = cfg.get("rg.name"); // ""
admin.resourcegroups().createResourceGroup(name, rg);
// after
String name = cfg.get("rg.name");
if (name == null || name.isEmpty()) throw new IllegalArgumentException("rg.name required");
admin.resourcegroups().createResourceGroup(name, rg);
Defensive patterns

Strategy: validation

Validate before calling

if (rgName == null || rgName.isEmpty()) {
    throw new IllegalArgumentException("Resource group name must be non-empty");
}

Type guard

boolean isValidRgName(String name) {
    return name != null && !name.trim().isEmpty();
}

Try / catch

try {
    createResourceGroupPath(name, config);
} catch (IllegalArgumentException e) {
    if (String.valueOf(e.getMessage()).contains("empty name")) {
        // correct name and retry
    } else throw e;
}

Prevention

When it happens

Trigger: Invoking the create path with rgName == "" — e.g. a variable never set, a template placeholder left blank, or an empty path segment from a malformed REST URL.

Common situations: Scripting/templating where the rg name variable is unset; REST clients building URLs with a missing path parameter; misconfigured pulsar-admin commands.

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/f8bae9b2d8ca32e1. Report an issue: GitHub.