apereo/cas · error · IllegalArgumentException
Cannot update a resource set without identifiers.
Error message
Cannot update a resource set without identifiers.
What it means
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.
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.
Example fix
// before ResourceSet updated = new ResourceSet(); // id == 0 repository.update(existing, updated); // throws // after updated.setId(existing.getId()); repository.update(existing, updated);
Defensive patterns
Strategy: validation
Validate before calling
if (current.getId() <= 0 || updated.getId() <= 0) {
throw new IllegalStateException("ResourceSet ids must be assigned before update");
} Try / catch
try { repository.update(current, updated); } catch (IllegalArgumentException e) {
return ResponseEntity.badRequest().body(Map.of("error", "missing_resource_set_id"));
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Cannot update a resource set with inconsistent/mismatched…
- Authentication request does contain a client id
- Resource set registration is missing scopes
- Resource-set owner does not match the authenticated profile
- Cannot save a resource set with inconsistent scopes.
AI-assisted analysis of apereo/cas@e7288fc434 (2026-09-08).
Data as JSON: /api/errors/336565756afe573a.
Report an issue: GitHub.
Appendix: source
Thrown at support/cas-server-support-oauth-uma-core/src/main/java/org/apereo/cas/uma/ticket/resource/repository/BaseResourceSetRepository.java:41
}
@Override
public long count() {
return getAll().size();
}
@Override
public ResourceSet save(final ResourceSet set) {
if (!validateResourceSetScopes(set)) {
throw new IllegalArgumentException("Cannot save a resource set with inconsistent scopes.");
}
return saveInternal(set);
}
@Override
public ResourceSet update(final ResourceSet currentResource, final ResourceSet newResource) {
if (currentResource.getId() <= 0 || newResource.getId() <= 0) {
throw new IllegalArgumentException("Cannot update a resource set without identifiers.");
}
if (currentResource.getId() != newResource.getId()) {
throw new IllegalArgumentException("Cannot update a resource set with inconsistent/mismatched identifiers.");
}
if (!validateResourceSetScopes(newResource)) {
throw new IllegalArgumentException("Cannot save a resource set with inconsistent scopes.");
}
currentResource.setOwner(newResource.getOwner());
currentResource.setClientId(newResource.getClientId());
currentResource.setName(newResource.getName());
currentResource.setIconUri(newResource.getIconUri());
currentResource.setPolicies(newResource.getPolicies());
currentResource.setScopes(newResource.getScopes());
currentResource.setType(newResource.getType());
currentResource.setUri(newResource.getUri());
return saveInternal(currentResource);View on GitHub (pinned to e7288fc434)