{"record":{"id":"b3fc6e9f52c64ddf","repo":"flowable/flowable-engine","slug":"identityidtype-allowed-values-are-1-and-2-b3fc6e","errorCode":null,"errorMessage":"identityIdType allowed values are 1 and 2","messagePattern":"identityIdType allowed values are 1 and 2","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AddIdentityLinkCmd.java","lineNumber":66,"sourceCode":"    }\n\n    protected void validateParams(String taskId, String identityId, int identityIdType, String identityType) {\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is null\");\n        }\n\n        if (identityType == null) {\n            throw new FlowableIllegalArgumentException(\"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 FlowableIllegalArgumentException(\"identityId is null\");\n        }\n\n        if (identityIdType != IDENTITY_USER && identityIdType != IDENTITY_GROUP) {\n            throw new FlowableIllegalArgumentException(\"identityIdType allowed values are 1 and 2\");\n        }\n    }\n\n    @Override\n    protected Void execute(CommandContext commandContext, TaskEntity task) {\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        \n        String oldAssigneeId = task.getAssignee();\n        String oldOwnerId = task.getOwner();\n        \n        boolean assignedToNoOne = false;\n        if (IdentityLinkType.ASSIGNEE.equals(identityType)) {\n            \n            if (oldAssigneeId == null && identityId == null) {\n                return null;\n            }\n            \n            if (oldAssigneeId != null && oldAssigneeId.equals(identityId)) {","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AddIdentityLinkCmd.java#L48-L84","documentation":"AddIdentityLinkCmd's identityIdType parameter must be IDENTITY_USER (1) or IDENTITY_GROUP (2); any other int is rejected with FlowableIllegalArgumentException because the engine cannot determine what kind of identity the link refers to.","triggerScenarios":"Constructing AddIdentityLinkCmd (or calling internal APIs) with identityIdType values like 0, 3, or an uninitialized int, or passing a boolean/other mapping mistakenly as the type int.","commonSituations":"Custom API wrappers computing the type with wrong constants, off-by-one enum-to-int mapping, deserialization defaulting the field to 0.","solutions":["Use the constants AddIdentityLinkCmd.IDENTITY_USER (1) / IDENTITY_GROUP (2) instead of raw literals","Map your enum to the engine constants in one place with validation","Prefer the higher-level TaskService methods (addUserIdentityLink / addGroupIdentityLink) which set the correct type automatically"],"exampleFix":"// before\nnew AddIdentityLinkCmd(taskId, identityId, 3, type);\n// after\nnew AddIdentityLinkCmd(taskId, identityId, AddIdentityLinkCmd.IDENTITY_GROUP, type);","handlingStrategy":"validation","validationCode":"if (identityIdType != 1 && identityIdType != 2) throw new IllegalArgumentException(\"identityIdType must be 1 (user) or 2 (group)\");","typeGuard":"boolean isValidIdentityIdType(int t) { return t == AddIdentityLinkCmd.IDENTITY_USER || t == AddIdentityLinkCmd.IDENTITY_GROUP; }","tryCatchPattern":"try {\n    new AddIdentityLinkCmd(taskId, identityId, identityIdType, type).execute(ctx);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Bad identityIdType: use IDENTITY_USER/IDENTITY_GROUP constants\", e);\n}","preventionTips":["Prefer addUserIdentityLink/addGroupIdentityLink over raw int types","Centralize enum-to-int mapping with validation","Avoid literals; use the class constants"],"tags":["cmmn","identity-link","invalid-value","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}