{"record":{"id":"f8bae9b2d8ca32e1","repo":"apache/pulsar","slug":"resourcegroupcreate-can-t-create-resource-group-w","errorCode":null,"errorMessage":"ResourceGroupCreate: can't create resource group with an empty name","messagePattern":"ResourceGroupCreate: can't create resource group with an empty name","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java","lineNumber":811,"sourceCode":"    }\n\n    private void initialize() {\n        // Store the configured interval. Do not start periodic tasks unconditionally here.\n        // Schedulers are started by maybeStartSchedulers() when the first tenant/namespace is registered.\n        final long periodInSecs = pulsar.getConfiguration().getResourceUsageTransportPublishIntervalInSecs();\n        this.aggregateLocalUsagePeriodInSeconds = this.resourceUsagePublishPeriodInSeconds = periodInSecs;\n        // if any tenant/namespace registrations already exist, maybeStartSchedulers() will start the schedulers now.\n        maybeStartSchedulers();\n    }\n\n    private void checkRGCreateParams(String rgName, org.apache.pulsar.common.policies.data.ResourceGroup rgConfig)\n      throws PulsarAdminException {\n        if (rgConfig == null) {\n            throw new IllegalArgumentException(\"ResourceGroupCreate: Invalid null ResourceGroup config\");\n        }\n\n        if (rgName.isEmpty()) {\n            throw new IllegalArgumentException(\"ResourceGroupCreate: can't create resource group with an empty name\");\n        }\n\n        ResourceGroup rg = getResourceGroupInternal(rgName);\n        if (rg != null) {\n            throw new PulsarAdminException(\"Resource group already exists:\" + rgName);\n        }\n    }\n    @Getter\n    private final PulsarService pulsar;\n\n    protected final ResourceQuotaCalculator quotaCalculator;\n    private ResourceUsageTransportManager resourceUsageTransportManagerMgr;\n\n    // rgConfigListener is used only through its side effects in the ctors, to set up RG/NS loading in config-listeners.\n    private final ResourceGroupConfigListener rgConfigListener;\n\n    // Given a RG-name, get the resource-group\n    private ConcurrentHashMap<String, ResourceGroup> resourceGroupsMap = new ConcurrentHashMap<>();","sourceCodeStart":793,"sourceCodeEnd":829,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java#L793-L829","documentation":"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.","triggerScenarios":"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.","commonSituations":"Scripting/templating where the rg name variable is unset; REST clients building URLs with a missing path parameter; misconfigured pulsar-admin commands.","solutions":["Provide a non-empty resource group name in the create call","Fix the script/template so the name variable is populated","Ensure the REST URL includes the group name path segment","Add client-side validation rejecting empty names before calling the API"],"exampleFix":"// before\nString name = cfg.get(\"rg.name\"); // \"\"\nadmin.resourcegroups().createResourceGroup(name, rg);\n// after\nString name = cfg.get(\"rg.name\");\nif (name == null || name.isEmpty()) throw new IllegalArgumentException(\"rg.name required\");\nadmin.resourcegroups().createResourceGroup(name, rg);","handlingStrategy":"validation","validationCode":"if (rgName == null || rgName.isEmpty()) {\n    throw new IllegalArgumentException(\"Resource group name must be non-empty\");\n}","typeGuard":"boolean isValidRgName(String name) {\n    return name != null && !name.trim().isEmpty();\n}","tryCatchPattern":"try {\n    createResourceGroupPath(name, config);\n} catch (IllegalArgumentException e) {\n    if (String.valueOf(e.getMessage()).contains(\"empty name\")) {\n        // correct name and retry\n    } else throw e;\n}","preventionTips":["Validate names in client code before API calls","Fail fast on unset template/CI variables supplying resource-group names","Enforce name format checks in tooling that constructs admin URLs"],"tags":["pulsar","admin-api","validation","illegal-argument"],"backgroundTag":"missing-required-parameter","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"}