{"record":{"id":"a03cc5d386a73dcc","repo":"flowable/flowable-engine","slug":"processinstanceid-is-null-a03cc5","errorCode":null,"errorMessage":"processInstanceId is null","messagePattern":"processInstanceId is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkForProcessInstanceCmd.java","lineNumber":49,"sourceCode":"\n    protected String userId;\n\n    protected String groupId;\n\n    protected String type;\n\n    public AddIdentityLinkForProcessInstanceCmd(String processInstanceId, String userId, String groupId, String type) {\n        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) {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkForProcessInstanceCmd.java#L31-L67","documentation":"AddIdentityLinkForProcessInstanceCmd attaches an identity link to a running process instance. validateParams requires a non-null processInstanceId because the link must target an existing execution. Flowable throws ActivitiIllegalArgumentException when it is null.","triggerScenarios":"Calling runtimeService.addUserIdentityLinkForProcessInstance(null, userId) or addGroupIdentityLinkForProcessInstance with null processInstanceId; constructing the command directly with null.","commonSituations":"The process instance was started asynchronously and the id variable was not yet assigned; a form/REST payload omitted the instance id; confusing processInstanceId with taskId.","solutions":["Pass a valid process instance id from runtimeService.startProcessInstance...(...) or a ProcessInstance.getId()","Null-check the id variable before the call","Ensure the REST/form layer actually supplies the instance id"],"exampleFix":"// before\nruntimeService.addUserIdentityLinkForProcessInstance(instanceId, userId, type); // null\n// after\nProcessInstance pi = runtimeService.startProcessInstanceByKey(\"myProcess\");\nruntimeService.addUserIdentityLinkForProcessInstance(pi.getId(), userId, type);","handlingStrategy":"validation","validationCode":"if (processInstanceId == null || processInstanceId.isEmpty()) {\n    throw new IllegalArgumentException(\"processInstanceId is required\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.addUserIdentityLinkForProcessInstance(pid, userId, null, type);\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"processInstanceId\")) {\n        // obtain a valid instance id before retrying\n    } else { throw e; }\n}","preventionTips":["Capture ProcessInstance.getId() immediately after starting the process","Null-check async start results before using the id","Keep processInstanceId and taskId variables clearly named and separate"],"tags":["null-argument","identity-link","process-instance","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-18T11:17:12.947Z"}