{"record":{"id":"e4c0569951c7bb23","repo":"apache/pulsar","slug":"resource-group-does-not-exist-name","errorCode":null,"errorMessage":"Resource group does not exist: ${name}","messagePattern":"Resource group does not exist: (.+?)","errorType":"exception","errorClass":"PulsarAdminException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java","lineNumber":165,"sourceCode":"            throw new PulsarAdminException(\"Resource group does not exist: \" + rgName);\n        }\n        rg.updateResourceGroup(rgConfig);\n        rgUpdates.labels(rgName).inc();\n    }\n\n    public Set<String> resourceGroupGetAll() {\n        return resourceGroupsMap.keySet();\n    }\n\n    /**\n     * Delete RG.\n     *\n     * @throws if RG with that name does not exist, or if the RG exists but is still in use.\n     */\n    public void resourceGroupDelete(String name) throws PulsarAdminException {\n        ResourceGroup rg = this.getResourceGroupInternal(name);\n        if (rg == null) {\n            throw new PulsarAdminException(\"Resource group does not exist: \" + name);\n        }\n\n        long tenantRefCount = rg.getResourceGroupNumOfTenantRefs();\n        long nsRefCount = rg.getResourceGroupNumOfNSRefs();\n        if ((tenantRefCount + nsRefCount) > 0) {\n            String errMesg = \"Resource group \" + name + \" still has \" + tenantRefCount + \" tenant refs\";\n            errMesg += \" and \" + nsRefCount + \" namespace refs on it\";\n            throw new PulsarAdminException(errMesg);\n        }\n\n        rg.resourceGroupPublishLimiter = null;\n        resourceGroupsMap.remove(name);\n    }\n\n    /**\n     * Get the current number of RGs. For testing.\n     */\n    protected long getNumResourceGroups() {","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java#L147-L183","documentation":"resourceGroupDelete throws PulsarAdminException when no resource group exists under the given name. Deletion requires an existing group; the follow-on check (error on tenant/namespace refs) only runs for existing groups.","triggerScenarios":"Calling resourceGroupDelete(name) when getResourceGroupInternal(name) returns null — the group was never created, already deleted, or the name is wrong.","commonSituations":"Double-delete from retry logic; typo in the name; deleting on the wrong cluster; cleanup scripts assuming groups exist from a prior environment.","solutions":["Verify the group exists with resourceGroupGet before deleting; treat not-found as success in idempotent cleanup.","Check the exact name spelling and target cluster.","If deletion races with another actor, catch PulsarAdminException with this message and continue.","If the group exists but delete still fails for refs, first remove tenant/namespace references (see the still-has-tenant-refs error)."],"exampleFix":"// before\nsvc.resourceGroupDelete(\"rg1\"); // fails if rg1 absent\n// after\ntry {\n  svc.resourceGroupDelete(\"rg1\");\n} catch (PulsarAdminException e) {\n  if (!e.getMessage().contains(\"does not exist\")) throw e; // idempotent delete\n}","handlingStrategy":"validation","validationCode":"if (!svc.resourceGroupGetAll().contains(name)) {\n  return; // already gone; treat delete as idempotent no-op\n}","typeGuard":null,"tryCatchPattern":"try {\n  svc.resourceGroupDelete(name);\n} catch (PulsarAdminException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Resource group does not exist\")) {\n    log.info(\"Resource group {} already deleted; ignoring\", name);\n  } else throw e;\n}","preventionTips":["Check existence before delete; skip if already absent","Treat delete retries carefully to avoid double-delete noise","Confirm the exact name and cluster before cleanup scripts run","Remove tenant/namespace refs before deleting an in-use group"],"tags":["broker","resource-group","not-found"],"backgroundTag":"resource-not-found","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"}