{"record":{"id":"336565756afe573a","repo":"apereo/cas","slug":"cannot-update-a-resource-set-without-identifiers","errorCode":null,"errorMessage":"Cannot update a resource set without identifiers.","messagePattern":"Cannot update a resource set without identifiers\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"support/cas-server-support-oauth-uma-core/src/main/java/org/apereo/cas/uma/ticket/resource/repository/BaseResourceSetRepository.java","lineNumber":41,"sourceCode":"    }\n\n    @Override\n    public long count() {\n        return getAll().size();\n    }\n\n    @Override\n    public ResourceSet save(final ResourceSet set) {\n        if (!validateResourceSetScopes(set)) {\n            throw new IllegalArgumentException(\"Cannot save a resource set with inconsistent scopes.\");\n        }\n        return saveInternal(set);\n    }\n\n    @Override\n    public ResourceSet update(final ResourceSet currentResource, final ResourceSet newResource) {\n        if (currentResource.getId() <= 0 || newResource.getId() <= 0) {\n            throw new IllegalArgumentException(\"Cannot update a resource set without identifiers.\");\n        }\n        if (currentResource.getId() != newResource.getId()) {\n            throw new IllegalArgumentException(\"Cannot update a resource set with inconsistent/mismatched identifiers.\");\n        }\n        if (!validateResourceSetScopes(newResource)) {\n            throw new IllegalArgumentException(\"Cannot save a resource set with inconsistent scopes.\");\n        }\n\n        currentResource.setOwner(newResource.getOwner());\n        currentResource.setClientId(newResource.getClientId());\n        currentResource.setName(newResource.getName());\n        currentResource.setIconUri(newResource.getIconUri());\n        currentResource.setPolicies(newResource.getPolicies());\n        currentResource.setScopes(newResource.getScopes());\n        currentResource.setType(newResource.getType());\n        currentResource.setUri(newResource.getUri());\n\n        return saveInternal(currentResource);","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/support/cas-server-support-oauth-uma-core/src/main/java/org/apereo/cas/uma/ticket/resource/repository/BaseResourceSetRepository.java#L23-L59","documentation":"Thrown by BaseResourceSetRepository.update when either the current or the new ResourceSet has an id <= 0, i.e. it was never persisted or was not loaded from the repository. Updates are keyed on the resource set identifier, so CAS refuses the operation when an identifier is absent. This is a precondition guard before any persistence is attempted.","triggerScenarios":"Calling update(current, new) with a transient ResourceSet (id defaults to 0) on either argument, e.g. passing a newly constructed ResourceSet instead of one fetched from the repository.","commonSituations":"Client-side code building a ResourceSet from a JSON payload without resolving the id; forgetting to call save() first to get an id; mapping code dropping the id field.","solutions":["Load both resource sets from the repository (or save the new one first) so each has a positive id.","Verify the id field is populated from the client's _id before calling update().","If the resource set is new, call save() instead of update().","Catch IllegalArgumentException and return a 400 error identifying the missing id."],"exampleFix":"// before\nResourceSet updated = new ResourceSet(); // id == 0\nrepository.update(existing, updated); // throws\n// after\nupdated.setId(existing.getId());\nrepository.update(existing, updated);","handlingStrategy":"validation","validationCode":"if (current.getId() <= 0 || updated.getId() <= 0) {\n    throw new IllegalStateException(\"ResourceSet ids must be assigned before update\");\n}","typeGuard":null,"tryCatchPattern":"try { repository.update(current, updated); } catch (IllegalArgumentException e) {\n    return ResponseEntity.badRequest().body(Map.of(\"error\", \"missing_resource_set_id\"));\n}","preventionTips":["Always fetch resource sets via findResourceSetById instead of reconstructing them","Ensure your JSON mapping preserves the _id field","Use save() for new entities and update() only for persisted ones"],"tags":["uma","oauth","resource-set","missing-identifier"],"backgroundTag":"missing-required-argument","analyzedSha":"e7288fc434b4f4505b8452e1a57e8fb3111bb863","analyzedAt":"2026-09-08T15:39:16.015Z","contentChangedAt":"2026-09-08T15:39:16.015Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}