{"record":{"id":"8d08497593364aa2","repo":"flowable/flowable-engine","slug":"userid-and-groupid-cannot-both-be-null-8d0849","errorCode":null,"errorMessage":"userId and groupId cannot both be null","messagePattern":"userId and groupId cannot both be null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkForProcessInstanceCmd.java","lineNumber":57,"sourceCode":"        validateParams(processInstanceId, userId, groupId, type);\n        this.processInstanceId = processInstanceId;\n        this.userId = userId;\n        this.groupId = groupId;\n        this.type = type;\n    }\n\n    protected void validateParams(String processInstanceId, String userId, String groupId, String type) {\n\n        if (processInstanceId == null) {\n            throw new ActivitiIllegalArgumentException(\"processInstanceId is null\");\n        }\n\n        if (type == null) {\n            throw new ActivitiIllegalArgumentException(\"type is required when adding a new process instance identity link\");\n        }\n\n        if (userId == null && groupId == null) {\n            throw new ActivitiIllegalArgumentException(\"userId and groupId cannot both be null\");\n        }\n\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n\n        ExecutionEntity processInstance = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);\n\n        if (processInstance == null) {\n            throw new ActivitiObjectNotFoundException(\"Cannot find process instance with id \" + processInstanceId, ExecutionEntity.class);\n        }\n\n        processInstance.addIdentityLink(userId, groupId, type);\n\n        commandContext.getHistoryManager().createProcessInstanceIdentityLinkComment(processInstanceId, userId, groupId, type, true);\n\n        return null;","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkForProcessInstanceCmd.java#L39-L75","documentation":"AddIdentityLinkForProcessInstanceCmd requires that at least one of userId or groupId is provided; an identity link must reference a user or a group. When both are null, validateParams throws ActivitiIllegalArgumentException.","triggerScenarios":"Calling runtimeService.addUserIdentityLinkForProcessInstance(pid, null, type) with both identifiers absent, or constructing the command with userId == null and groupId == null.","commonSituations":"Empty form submissions where neither user nor group was filled in; upstream user-directory lookup returned null for both; swapped arguments placing the type where userId should be.","solutions":["Provide a userId or a groupId (one of them must be non-null)","Validate inputs before the call and reject empty user/group pairs","Check argument order: signature is (processInstanceId, userId, groupId, type)"],"exampleFix":"// before\nruntimeService.addUserIdentityLinkForProcessInstance(pid, userId, groupId, type); // both null\n// after\nif (userId == null && groupId == null) {\n    throw new IllegalArgumentException(\"userId or groupId required\");\n}\nruntimeService.addUserIdentityLinkForProcessInstance(pid, userId, groupId, type);","handlingStrategy":"validation","validationCode":"if (userId == null && groupId == null) {\n    throw new IllegalArgumentException(\"userId or groupId is required\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.addUserIdentityLinkForProcessInstance(pid, userId, groupId, type);\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"both be null\")) {\n        // reject the request or supply a default identity\n    } else { throw e; }\n}","preventionTips":["Validate that user/group resolution produced at least one id","Check the (processInstanceId, userId, groupId, type) argument order","Reject empty form submissions before they reach the engine"],"tags":["null-argument","identity-link","process-instance","validation"],"backgroundTag":"mutually-exclusive-options","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"}