{"record":{"id":"8d5b694b5d2c4252","repo":"flowable/flowable-engine","slug":"taskid-is-null-8d5b69","errorCode":null,"errorMessage":"taskId is null","messagePattern":"taskId 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":52,"sourceCode":"\n    protected String identityId;\n\n    protected int identityIdType;\n\n    protected String identityType;\n\n    public AddIdentityLinkCmd(String taskId, String identityId, int identityIdType, String identityType) {\n        super(taskId);\n        validateParams(taskId, identityId, identityIdType, identityType);\n        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","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AddIdentityLinkCmd.java#L34-L70","documentation":"AddIdentityLinkCmd.validateParams rejects a null taskId because an identity link (user/group association) can only be attached to an existing task. It throws FlowableIllegalArgumentException before any entity lookup or persistence happens.","triggerScenarios":"Calling cmmnTaskService.addUserIdentityLink(null, userId, type), addGroupIdentityLink(null, ...), or new AddIdentityLinkCmd(null, ...) where the taskId parameter was never set (e.g. null from an upstream map/request param).","commonSituations":"REST/DTO layer passing through an unset taskId, a variable holding the task id being null after a failed task query, or wiring the wrong variable into the service call.","solutions":["Ensure the task exists and capture its id before adding an identity link","Null-check taskId at the caller and fail with a clear client-facing message","Use taskService.createTaskQuery().taskId(id) to verify existence, then use task.getId()"],"exampleFix":"// before\ntaskService.addUserIdentityLink(taskId, userId, IdentityLinkType.PARTICIPANT);\n// after\nif (taskId == null) throw new IllegalArgumentException(\"taskId is required\");\ntaskService.addUserIdentityLink(taskId, userId, IdentityLinkType.PARTICIPANT);","handlingStrategy":"validation","validationCode":"if (taskId == null || taskId.isBlank()) throw new IllegalArgumentException(\"taskId is required\");\ntaskService.addUserIdentityLink(taskId, userId, IdentityLinkType.PARTICIPANT);","typeGuard":"boolean hasTaskId(String taskId) { return taskId != null && !taskId.isBlank(); }","tryCatchPattern":"try {\n    taskService.addUserIdentityLink(taskId, userId, type);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(e.getMessage());\n}","preventionTips":["Always derive taskId from a successful task query result","Validate request/DTO fields before calling engine APIs","Don't pass through nullable ids from upstream layers unchecked"],"tags":["cmmn","null-check","identity-link","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"}