{"record":{"id":"2a89375d9d93e4d3","repo":"flowable/flowable-engine","slug":"processinstanceid-is-required","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/GetHistoricEntityLinkChildrenForProcessInstanceCmd.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 Tijs Rademakers\n */\npublic class GetHistoricEntityLinkChildrenForProcessInstanceCmd implements Command<List<HistoricEntityLink>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String processInstanceId;\n\n    public GetHistoricEntityLinkChildrenForProcessInstanceCmd(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                .findHistoricEntityLinksByScopeIdAndScopeType(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/GetHistoricEntityLinkChildrenForProcessInstanceCmd.java#L19-L50","documentation":"The GetHistoricEntityLinkChildrenForProcessInstanceCmd constructor requires a processInstanceId and throws FlowableIllegalArgumentException when it is null. Entity links relate a process instance to its child entities (sub-processes, tasks), so the id is mandatory to perform the historic query.","triggerScenarios":"new GetHistoricEntityLinkChildrenForProcessInstanceCmd(null), typically when the historic process instance's id is read from a variable or optional lookup that resolved to null.","commonSituations":"Querying entity links for a process instance that has already been fully purged from history; passing runtimeExecutionId instead of processInstanceId; null returned by HistoricProcessInstance.getId() after a failed query.","solutions":["Provide a valid, non-null historic process instance id before constructing the command.","Validate the id at the call site and skip the query when absent.","Confirm you obtained the id from the historic process instance (not a deleted runtime one) via runtimeService/historyService."],"exampleFix":"// before\nhistoryService.findHistoricEntityLinkChildrenForProcessInstance(instanceId);\n// after\nif (instanceId == null) {\n    throw new IllegalArgumentException(\"Historic process instance id must be set\");\n}\nhistoryService.findHistoricEntityLinkChildrenForProcessInstance(instanceId);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(processInstanceId, \"processInstanceId is required to query historic entity link children\");","typeGuard":null,"tryCatchPattern":"try {\n    return historyService.findHistoricEntityLinkChildrenForProcessInstance(processInstanceId);\n} catch (FlowableIllegalArgumentException e) {\n    return Collections.emptyList();\n}","preventionTips":["Null-check the id at the boundary where it is captured","Get ids directly from HistoricProcessInstance objects, not from optional lookups","Account for history cleanup jobs when scheduling link queries"],"tags":["flowable","argument-validation","entity-links","history"],"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"}