{"record":{"id":"faf64937eb090656","repo":"flowable/flowable-engine","slug":"identityid-is-null-faf649","errorCode":null,"errorMessage":"identityId is null","messagePattern":"identityId is null","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":62,"sourceCode":"        this.taskId = taskId;\n        this.identityId = identityId;\n        this.identityIdType = identityIdType;\n        this.identityType = identityType;\n    }\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) {","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AddIdentityLinkCmd.java#L44-L80","documentation":"AddIdentityLinkCmd requires identityId (the user or group id) to be non-null unless the link type is ASSIGNEE or OWNER added as user-type where the id is implied by context. When identityId is null and the type demands one (groups, or any type other than assignee/owner), FlowableIllegalArgumentException is thrown.","triggerScenarios":"Calling cmmnTaskService.addGroupIdentityLink(taskId, null, type), or addUserIdentityLink with a null userId for a type other than ASSIGNEE/OWNER — i.e. the resolved user/group id was null.","commonSituations":"User directory lookup returned no match so the id variable stayed null, form/DTO omitted the identity field, or a caller confused userId/group arguments and passed null.","solutions":["Resolve and pass the actual user/group id; verify it is non-null before the call","Use setAssignee/setOwner instead of addIdentityLink when the intent is assignee/owner without an explicit identity lookup","Validate input at the API boundary so null identity ids are rejected with a clear message"],"exampleFix":"// before\ntaskService.addGroupIdentityLink(taskId, groupId, IdentityLinkType.PARTICIPANT); // groupId == null\n// after\nif (groupId == null) throw new IllegalArgumentException(\"groupId is required\");\ntaskService.addGroupIdentityLink(taskId, groupId, IdentityLinkType.PARTICIPANT);","handlingStrategy":"validation","validationCode":"if (identityId == null && !IdentityLinkType.ASSIGNEE.equals(type) && !IdentityLinkType.OWNER.equals(type)) {\n    throw new IllegalArgumentException(\"identityId is required for type \" + type);\n}","typeGuard":"boolean hasIdentity(String id, String type) {\n    return id != null || IdentityLinkType.ASSIGNEE.equals(type) || IdentityLinkType.OWNER.equals(type);\n}","tryCatchPattern":"try {\n    taskService.addGroupIdentityLink(taskId, groupId, type);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(\"Missing user/group id: \" + e.getMessage());\n}","preventionTips":["Resolve the user/group from the directory first and null-check the result","Use setAssignee/setOwner for assignee/owner semantics","Validate identity fields at the API boundary"],"tags":["cmmn","identity-link","null-check","validation"],"backgroundTag":"null-argument","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"}