flowable/flowable-engine · error · ActivitiException
Cannot assign a groupId to a task assignment that already…
Error message
Cannot assign a groupId to a task assignment that already has a userId
What it means
Consistency guard in flowable5 IdentityLinkEntity.setGroupId: the identity link already has a userId set, and assigning a groupId as well would make the link ambiguous (both a user and a group). The entity enforces mutual exclusivity of userId and groupId.
Solutions
- Create a separate identity link for the group; use taskService.addCandidateGroup / addGroupIdentityLink.
- Null out userId first only if you truly intend to convert the link.
- Map external 'assignee OR group' inputs to two distinct API calls.
Example fix
// before
link.setUserId("kermit"); link.setGroupId("management"); // throws
// after
taskService.setAssignee(taskId, "kermit");
taskService.addCandidateGroup(taskId, "management"); Defensive patterns
Strategy: validation
Validate before calling
if (link.getUserId() != null && groupId != null) {
throw new IllegalArgumentException("cannot assign group to user-based link");
} Type guard
function isGroupLinkAssignable(link) {
return link.getUserId() == null;
} Try / catch
try {
taskService.addCandidateGroup(taskId, groupId);
} catch (ActivitiException e) {
log.warn("Link conflict on task {}: {}", taskId, e.getMessage());
} Prevention
- Separate assignee and candidate-group operations into distinct calls
- Avoid reusing IdentityLinkEntity instances across assignments
- Validate external assignment payloads for user+group conflicts
When it happens
Trigger: Calling setGroupId on an IdentityLinkEntity whose userId is already non-null; assignment code that sets assignee first and then tries to add a group on the same entity.
Common situations: Custom task assignment listeners combining assignee and candidate group in one entity; converters that map 'assignee or group' fields from external systems onto a single link; reuse of entity instances across task assignments.
Related errors
- Cannot assign a userId to a task assignment that already…
- Cannot assign a groupId to a task assignment that already…
- Cannot assign a userId to a task assignment that already…
- identityId is null
- task not found
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/c6c2b7cf524f249b.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/entity/IdentityLinkEntity.java:149
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
if (this.groupId != null && userId != null) {
throw new ActivitiException("Cannot assign a userId to a task assignment that already has a groupId");
}
this.userId = userId;
}
@Override
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
if (this.userId != null && groupId != null) {
throw new ActivitiException("Cannot assign a groupId to a task assignment that already has a userId");
}
this.groupId = groupId;
}
@Override
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
@Override
public String getProcessInstanceId() {
return processInstanceId;
}
View on GitHub (pinned to d6d39ce1c6)