{"record":{"id":"a3e52e2733baaba3","repo":"flowable/flowable-engine","slug":"identityidtype-allowed-values-are-1-and-2-a3e52e","errorCode":null,"errorMessage":"identityIdType allowed values are 1 and 2","messagePattern":"identityIdType allowed values are 1 and 2","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkCmd.java","lineNumber":61,"sourceCode":"    }\n\n    protected void validateParams(String taskId, String identityId, int identityIdType, String identityType) {\n        if (taskId == null) {\n            throw new ActivitiIllegalArgumentException(\"taskId is null\");\n        }\n\n        if (identityType == null) {\n            throw new ActivitiIllegalArgumentException(\"type is required when adding a new task identity link\");\n        }\n\n        if (identityId == null && (identityIdType == IDENTITY_GROUP ||\n                (!IdentityLinkType.ASSIGNEE.equals(identityType) && !IdentityLinkType.OWNER.equals(identityType)))) {\n\n            throw new ActivitiIllegalArgumentException(\"identityId is null\");\n        }\n\n        if (identityIdType != IDENTITY_USER && identityIdType != IDENTITY_GROUP) {\n            throw new ActivitiIllegalArgumentException(\"identityIdType allowed values are 1 and 2\");\n        }\n    }\n\n    @Override\n    protected Void execute(CommandContext commandContext, TaskEntity task) {\n\n        boolean assignedToNoOne = false;\n        if (IdentityLinkType.ASSIGNEE.equals(identityType)) {\n            task.setAssignee(identityId, true, true);\n            assignedToNoOne = identityId == null;\n        } else if (IdentityLinkType.OWNER.equals(identityType)) {\n            task.setOwner(identityId, true);\n        } else if (IDENTITY_USER == identityIdType) {\n            task.addUserIdentityLink(identityId, identityType);\n        } else if (IDENTITY_GROUP == identityIdType) {\n            task.addGroupIdentityLink(identityId, identityType);\n        }\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkCmd.java#L43-L79","documentation":"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.","triggerScenarios":"Constructing AddIdentityLinkCmd directly with identityIdType of 0, 3, -1, or an uninitialized default; mapping a boolean/string id type to the wrong int.","commonSituations":"Using 0 as a 'none/default' value; passing IdentityLinkType string constants into the int parameter; off-by-one errors in a custom mapping.","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"],"exampleFix":"// before\nnew AddIdentityLinkCmd(taskId, identityId, 3, identityType);\n// after\nnew AddIdentityLinkCmd(taskId, identityId, AddIdentityLinkCmd.IDENTITY_USER, identityType);","handlingStrategy":"validation","validationCode":"if (identityIdType != 1 && identityIdType != 2) {\n    throw new IllegalArgumentException(\"identityIdType must be 1 (user) or 2 (group)\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    new AddIdentityLinkCmd(taskId, identityId, identityIdType, type).execute(ctx);\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"identityIdType\")) {\n        // map or reject the value before retrying\n    } else { throw e; }\n}","preventionTips":["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"],"tags":["invalid-argument","enum","identity-link","legacy-api"],"backgroundTag":"invalid-enum-value","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}