{"record":{"id":"f814632f85b801c1","repo":"flowable/flowable-engine","slug":"processinstanceid-is-required-f81463","errorCode":null,"errorMessage":"processInstanceId is required","messagePattern":"processInstanceId is required","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetHistoricEntityLinkParentsForProcessInstanceCmd.java","lineNumber":37,"sourceCode":"import org.flowable.common.engine.api.scope.ScopeTypes;\nimport org.flowable.common.engine.impl.interceptor.Command;\nimport org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;\nimport org.flowable.engine.impl.util.CommandContextUtil;\nimport org.flowable.entitylink.api.EntityLinkType;\nimport org.flowable.entitylink.api.history.HistoricEntityLink;\n\n/**\n * @author Javier Casal\n */\npublic class GetHistoricEntityLinkParentsForProcessInstanceCmd implements Command<List<HistoricEntityLink>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String processInstanceId;\n\n    public GetHistoricEntityLinkParentsForProcessInstanceCmd(String processInstanceId) {\n        if (processInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"processInstanceId is required\");\n        }\n        this.processInstanceId = processInstanceId;\n    }\n\n    @Override\n    public List<HistoricEntityLink> execute(CommandContext commandContext) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        return processEngineConfiguration.getEntityLinkServiceConfiguration().getHistoricEntityLinkService()\n                .findHistoricEntityLinksByReferenceScopeIdAndType(processInstanceId, ScopeTypes.BPMN, EntityLinkType.CHILD);\n    }\n\n}\n","sourceCodeStart":19,"sourceCodeEnd":50,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetHistoricEntityLinkParentsForProcessInstanceCmd.java#L19-L50","documentation":"The GetHistoricEntityLinkParentsForProcessInstanceCmd constructor requires a processInstanceId and throws FlowableIllegalArgumentException when it is null. Parent entity links describe the ancestor chain (parent process/case instances) of a process instance and cannot be resolved without the id.","triggerScenarios":"new GetHistoricEntityLinkParentsForProcessInstanceCmd(null) — commonly when walking a hierarchy and a root process instance (which has no parent references) yields a null parent id, or a lookup returned null.","commonSituations":"Traversing parent entity links upward and passing a null for the root; process instance purged from history; mixing up execution id with process instance id.","solutions":["Pass the process instance id from HistoricProcessInstance.getId() after confirming the instance exists.","Guard for null at each step of the hierarchy traversal and stop when the id is absent (root reached).","Use the process instance id, not the execution id, when constructing the command."],"exampleFix":"// before\nString parentId = current.getParentId();\nhistoryService.findHistoricEntityLinkParentsForProcessInstance(parentId);\n// after\nif (current.getParentId() == null) {\n    return; // reached the root process instance\n}\nhistoryService.findHistoricEntityLinkParentsForProcessInstance(current.getParentId());","handlingStrategy":"validation","validationCode":"if (processInstanceId == null) { return Collections.emptyList(); /* root instance: no parents */ }","typeGuard":null,"tryCatchPattern":"try {\n    return historyService.findHistoricEntityLinkParentsForProcessInstance(processInstanceId);\n} catch (FlowableIllegalArgumentException e) {\n    return Collections.emptyList();\n}","preventionTips":["Treat a null parent id as the root condition, not an error path","Pass process instance ids (not execution ids) to parent-link lookups","Null-check at every step of upward traversals"],"tags":["flowable","argument-validation","entity-links","hierarchy"],"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"}