{"record":{"id":"c8fd1fae215344cf","repo":"apache/pulsar","slug":"resourcegroupupdate-invalid-null-resourcegroup-co","errorCode":null,"errorMessage":"ResourceGroupUpdate: Invalid null ResourceGroup config","messagePattern":"ResourceGroupUpdate: Invalid null ResourceGroup config","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java","lineNumber":142,"sourceCode":"    public ResourceGroup resourceGroupGet(String resourceGroupName) {\n        ResourceGroup retrievedRG = this.getResourceGroupInternal(resourceGroupName);\n        if (retrievedRG == null) {\n            return null;\n        }\n\n        // Return a copy.\n        return new ResourceGroup(retrievedRG);\n    }\n\n    /**\n     * Update RG.\n     *\n     * @throws if RG with that name does not exist.\n     */\n    public void resourceGroupUpdate(String rgName, org.apache.pulsar.common.policies.data.ResourceGroup rgConfig)\n      throws PulsarAdminException {\n        if (rgConfig == null) {\n            throw new IllegalArgumentException(\"ResourceGroupUpdate: Invalid null ResourceGroup config\");\n        }\n\n        ResourceGroup rg = this.getResourceGroupInternal(rgName);\n        if (rg == null) {\n            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.","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java#L124-L160","documentation":"ResourceGroupService.resourceGroupUpdate rejects a null ResourceGroup config with IllegalArgumentException before touching stored state. Updating a resource group requires a fully specified configuration object.","triggerScenarios":"Calling resourceGroupUpdate(rgName, null), typically when admin code builds the config from a request body that was empty or failed to deserialize.","commonSituations":"Admin REST call with missing/empty JSON body mapped to null; programmatically constructing ResourceGroup config and forgetting to populate it; upstream deserialization failure silently yielding null.","solutions":["Construct and populate a ResourceGroup config object before calling resourceGroupUpdate.","In admin/REST paths, validate the request body is present and parses into a ResourceGroup before invoking the service.","Check client serialization so the config isn't dropped during transport.","Use resourceGroupGet or resourceGroupCreate if you intended to read or create rather than update."],"exampleFix":"// before\nadmin.resourcegroups().updateResourceGroup(\"rg1\", null);\n// after\nResourceGroup cfg = new ResourceGroup();\ncfg.setPublishRate(new PublishRate(1000, 10));\nadmin.resourcegroups().updateResourceGroup(\"rg1\", cfg);","handlingStrategy":"validation","validationCode":"java.util.Objects.requireNonNull(rgConfig, \"ResourceGroup config must not be null\");\n// also check required fields\nif (rgConfig.getPubRateInMsgs() <= 0 && rgConfig.getDispatchRateInMsgs() <= 0)\n  log.warn(\"ResourceGroup config has no rates set\");","typeGuard":null,"tryCatchPattern":"try {\n  svc.resourceGroupUpdate(rgName, rgConfig);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Invalid null ResourceGroup config\")) {\n    log.error(\"Config was null; check request body deserialization for \" + rgName);\n  }\n  throw e;\n}","preventionTips":["Validate the admin request body is non-empty before mapping to ResourceGroup","Construct the config with required rates before calling update","Make REST endpoints return 4xx for missing bodies instead of passing null down","Add a null check at the API boundary"],"tags":["broker","resource-group","null-check","validation"],"backgroundTag":"null-configuration","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"}