{"record":{"id":"8f4cca267be5650f","repo":"flowable/flowable-engine","slug":"processinstanceid-is-null-8f4cca","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/DeleteIdentityLinkForProcessInstanceCmd.java","lineNumber":49,"sourceCode":"    protected String processInstanceId;\n\n    protected String userId;\n\n    protected String groupId;\n\n    protected String type;\n\n    public DeleteIdentityLinkForProcessInstanceCmd(String processInstanceId, String userId, String groupId, String type) {\n        validateParams(userId, groupId, processInstanceId, type);\n        this.processInstanceId = processInstanceId;\n        this.userId = userId;\n        this.groupId = groupId;\n        this.type = type;\n    }\n\n    protected void validateParams(String userId, String groupId, String processInstanceId, String type) {\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 deleting a process 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    @Override\n    public Void execute(CommandContext commandContext) {\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        }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteIdentityLinkForProcessInstanceCmd.java#L31-L67","documentation":"Activiti/Flowable 5 throws this ActivitiIllegalArgumentException from DeleteIdentityLinkForProcessInstanceCmd when deleting a process-instance identity link without a processInstanceId. The command validates required parameters before touching the engine, refusing to proceed with a null execution id because the target process instance could never be located.","triggerScenarios":"Calling RuntimeService.deleteProcessInstanceIdentityLink(processInstanceId, userId, groupId, type) (or the equivalent IdentityLinkService command path) with processInstanceId == null.","commonSituations":"A variable holding the process instance id was never populated (e.g. an execution variable read back as null, or a standalone task with no process scope); also confusing taskId with processInstanceId in API calls.","solutions":["Resolve a non-null processInstanceId before calling (e.g. taskService.createTaskQuery().taskId(taskId).singleResult().getProcessInstanceId()).","If working from a task with no process instance, use task identity-link APIs instead: taskService.deleteUserIdentityLink / deleteGroupIdentityLink.","Validate inputs early: skip or throw when processInstanceId is null before invoking the engine.","Use executionEntity.getId() from a live ExecutionEntity rather than a possibly-null cached value."],"exampleFix":"// before\nruntimeService.deleteProcessInstanceIdentityLink(procInstId, userId, null, \"candidate\");\n// after\nif (procInstId == null) {\n    procInstId = taskService.createTaskQuery().taskId(taskId).singleResult().getProcessInstanceId();\n}\nruntimeService.deleteProcessInstanceIdentityLink(procInstId, userId, null, \"candidate\");","handlingStrategy":"validation","validationCode":"if (processInstanceId == null || processInstanceId.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"processInstanceId must be resolved before deleting an identity link\");\n}","typeGuard":"boolean hasProcessInstanceId(String id) { return id != null && !id.trim().isEmpty(); }","tryCatchPattern":"try {\n    runtimeService.deleteProcessInstanceIdentityLink(pid, userId, groupId, type);\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"processInstanceId is null\")) {\n        throw new IllegalStateException(\"Caller bug: missing processInstanceId\", e);\n    }\n    throw e;\n}","preventionTips":["Always obtain the id from a live Task/Execution/ProcessInstance object, not a nullable local variable.","Prefer taskService identity-link APIs for tasks without process scope.","Validate inputs at the service boundary before invoking engine commands.","Log the full argument set when engine calls fail to spot missing arguments early."],"tags":["null-argument","process-instance","identity-link","validation"],"backgroundTag":"missing-required-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"}