flowable/flowable-engine · error · ActivitiIllegalArgumentException
identityIdType allowed values are 1 and 2
Error message
identityIdType allowed values are 1 and 2
What it means
AddIdentityLinkCmd accepts identityIdType as an int flag: 1 = user, 2 = group. Any other value is rejected with ActivitiIllegalArgumentException because the command cannot tell what kind of identity link is being created.
Solutions
- Pass AddIdentityLinkCmd.IDENTITY_USER (1) or IDENTITY_GROUP (2) instead of a literal
- Prefer the newer userId/group-based constructors that do not take the int flag
- Add an enum or constants wrapper so callers cannot pass arbitrary ints
Example fix
// before new AddIdentityLinkCmd(taskId, identityId, 3, identityType); // after new AddIdentityLinkCmd(taskId, identityId, AddIdentityLinkCmd.IDENTITY_USER, identityType);
Defensive patterns
Strategy: validation
Validate before calling
if (identityIdType != 1 && identityIdType != 2) {
throw new IllegalArgumentException("identityIdType must be 1 (user) or 2 (group)");
} Try / catch
try {
new AddIdentityLinkCmd(taskId, identityId, identityIdType, type).execute(ctx);
} catch (ActivitiIllegalArgumentException e) {
if (e.getMessage().contains("identityIdType")) {
// map or reject the value before retrying
} else { throw e; }
} Prevention
- Use the IDENTITY_USER/IDENTITY_GROUP constants, never literals
- Prefer constructors that take userId/groupId strings directly
- Wrap the int flag in a small enum in your own code
When it happens
Trigger: Constructing AddIdentityLinkCmd directly with identityIdType of 0, 3, -1, or an uninitialized default; mapping a boolean/string id type to the wrong int.
Common situations: Using 0 as a 'none/default' value; passing IdentityLinkType string constants into the int parameter; off-by-one errors in a custom mapping.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- identityIdType allowed values are 1 and 2
- Incompatible usage: cannot use type
- Invalid action: ''.
- A group or a user is required to create an identity link.
- A group or a user is required to create an identity link.
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/a3e52e2733baaba3.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkCmd.java:61
}
protected void validateParams(String taskId, String identityId, int identityIdType, String identityType) {
if (taskId == null) {
throw new ActivitiIllegalArgumentException("taskId is null");
}
if (identityType == null) {
throw new ActivitiIllegalArgumentException("type is required when adding a new task identity link");
}
if (identityId == null && (identityIdType == IDENTITY_GROUP ||
(!IdentityLinkType.ASSIGNEE.equals(identityType) && !IdentityLinkType.OWNER.equals(identityType)))) {
throw new ActivitiIllegalArgumentException("identityId is null");
}
if (identityIdType != IDENTITY_USER && identityIdType != IDENTITY_GROUP) {
throw new ActivitiIllegalArgumentException("identityIdType allowed values are 1 and 2");
}
}
@Override
protected Void execute(CommandContext commandContext, TaskEntity task) {
boolean assignedToNoOne = false;
if (IdentityLinkType.ASSIGNEE.equals(identityType)) {
task.setAssignee(identityId, true, true);
assignedToNoOne = identityId == null;
} else if (IdentityLinkType.OWNER.equals(identityType)) {
task.setOwner(identityId, true);
} else if (IDENTITY_USER == identityIdType) {
task.addUserIdentityLink(identityId, identityType);
} else if (IDENTITY_GROUP == identityIdType) {
task.addGroupIdentityLink(identityId, identityType);
}
View on GitHub (pinned to d6d39ce1c6)