Activiti/Activiti · error · ActivitiIllegalArgumentException
identityIdType allowed values are 1 and 2
Error message
identityIdType allowed values are 1 and 2
What it means
validateParams() last check: identityIdType must be exactly IDENTITY_USER (1) or IDENTITY_GROUP (2). Any other int (typically 0 from an uninitialized field or an out-of-range value) triggers ActivitiIllegalArgumentException. This API is an older integer-typed variant kept alongside the string IdentityLinkType overloads.
Solutions
- Pass only IDENTITY_USER (1) or IDENTITY_GROUP (2) constants from the class, never raw literals.
- Prefer the string-based overloads (taskService.addUserIdentityLink / addGroupIdentityLink) which avoid the int typing entirely.
- Validate/mapping-lookup the int before calling; reject unknown role names at configuration load time.
- Fix default initialization so the field defaults to a valid code rather than 0.
Example fix
// before int identityIdType = 0; // defaults to 0 -> rejected // after int identityIdType = isGroup ? AddIdentityLinkCmd.IDENTITY_GROUP : AddIdentityLinkCmd.IDENTITY_USER;
Defensive patterns
Strategy: validation
Validate before calling
if (identityIdType != IDENTITY_USER && identityIdType != IDENTITY_GROUP) {
throw new IllegalArgumentException("identityIdType must be 1 (user) or 2 (group)");
} Try / catch
try {
taskService.addIdentityLink(taskId, identityId, identityIdType, identityType);
} catch (ActivitiIllegalArgumentException e) {
log.error("identityIdType must be 1 or 2", e);
} Prevention
- Only use the IDENTITY_USER/IDENTITY_GROUP constants, never magic numbers.
- Prefer string-based overloads (addUserIdentityLink/addGroupIdentityLink) over the int variant.
- Map external role names to these constants once, with validation at load time.
When it happens
Trigger: Calling the int-based addIdentityLink variant (taskService.addIdentityLink-like overloads taking an int) with 0, 3, or any value other than 1 or 2 — commonly an unset field defaulting to 0.
Common situations: Hand-maintained mappings converting user/group roles to ints with no default; values loaded from external config where 'user'/'group' strings weren't recognized; legacy integrations using wrong numeric codes.
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
- identityId is null
- processInstanceId is null
- type is required when adding a new task identity link
- type is required when deleting a process identity link
- userId and groupId cannot both be null
AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09).
Data as JSON: /api/errors/ce4d0adb78b81b40.
Report an issue: GitHub.
Appendix: source
Thrown at activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkCmd.java:78
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");
}
}
protected Void execute(CommandContext commandContext, TaskEntity task) {
boolean assignedToNoOne = false;
if (IdentityLinkType.ASSIGNEE.equals(identityType)) {
commandContext.getTaskEntityManager().changeTaskAssignee(task, identityId);
assignedToNoOne = identityId == null;
} else if (IdentityLinkType.OWNER.equals(identityType)) {
commandContext.getTaskEntityManager().changeTaskOwner(task, identityId);
} else if (IDENTITY_USER == identityIdType) {
task.addUserIdentityLink(identityId, identityType, details);
} else if (IDENTITY_GROUP == identityIdType) {
task.addGroupIdentityLink(identityId, identityType);
}
boolean forceNullUserId = false;
if (assignedToNoOne) {View on GitHub (pinned to 56435b1a97)