{"record":{"id":"7b9dae59e4f76df6","repo":"flowable/flowable-engine","slug":"processinstanceid-is-required-7b9dae","errorCode":null,"errorMessage":"processInstanceId is required","messagePattern":"processInstanceId is required","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetHistoricEntityLinkChildrenWithSameRootAsProcessInstanceCmd.java","lineNumber":35,"sourceCode":"import org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport 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 Filip Hrisafov\n */\npublic class GetHistoricEntityLinkChildrenWithSameRootAsProcessInstanceCmd implements Command<List<HistoricEntityLink>> {\n\n    protected String processInstanceId;\n\n    public GetHistoricEntityLinkChildrenWithSameRootAsProcessInstanceCmd(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                .findHistoricEntityLinksWithSameRootScopeForScopeIdAndScopeType(processInstanceId, ScopeTypes.BPMN, EntityLinkType.CHILD);\n    }\n\n}\n","sourceCodeStart":17,"sourceCodeEnd":48,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetHistoricEntityLinkChildrenWithSameRootAsProcessInstanceCmd.java#L17-L48","documentation":"GetHistoricEntityLinkChildrenWithSameRootAsProcessInstanceCmd requires a processInstanceId and throws FlowableIllegalArgumentException when null. This command queries historic entity links that share the same root scope as the given process instance, so the id is mandatory.","triggerScenarios":"new GetHistoricEntityLinkChildrenWithSameRootAsProcessInstanceCmd(null), typically from a null result of a process-instance lookup or an uninitialized variable at the caller.","commonSituations":"Navigating process-instance hierarchies where a parent/child instance id was never set; querying after history cleanup removed the instance; passing a task id or execution id instead of the process instance id.","solutions":["Supply a non-null process instance id obtained from the runtime or historic process instance object.","Validate before constructing the command and skip/return empty on null.","Verify the id type: this API expects the process instance id, not execution or task ids."],"exampleFix":"// before\nhistoryService.findHistoricEntityLinksWithSameRootAsProcessInstance(piId);\n// after\nif (piId == null) {\n    return Collections.emptyList();\n}\nhistoryService.findHistoricEntityLinksWithSameRootAsProcessInstance(piId);","handlingStrategy":"validation","validationCode":"if (processInstanceId == null) { return Collections.emptyList(); }","typeGuard":null,"tryCatchPattern":"try {\n    return historyService.findHistoricEntityLinksWithSameRootAsProcessInstance(processInstanceId);\n} catch (FlowableIllegalArgumentException e) {\n    return Collections.emptyList();\n}","preventionTips":["Stop hierarchy traversals when the instance id becomes null","Verify ids against the history service before dependent queries","Keep root/parent id fields nullable and branch explicitly"],"tags":["flowable","argument-validation","entity-links","process-instance"],"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"}