{"record":{"id":"1f0cd67b4e7617f1","repo":"flowable/flowable-engine","slug":"cannot-find-process-instance-with-id-processinst-1f0cd6","errorCode":null,"errorMessage":"Cannot find process instance with id ${processInstanceId}","messagePattern":"Cannot find process instance with id (.+?)","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetEntityLinkParentsForProcessInstanceCmd.java","lineNumber":47,"sourceCode":" * @author Javier Casal\n */\npublic class GetEntityLinkParentsForProcessInstanceCmd implements Command<List<EntityLink>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String processInstanceId;\n\n    public GetEntityLinkParentsForProcessInstanceCmd(String processInstanceId) {\n        this.processInstanceId = processInstanceId;\n    }\n\n    @Override\n    public List<EntityLink> execute(CommandContext commandContext) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        ExecutionEntity processInstance = processEngineConfiguration.getExecutionEntityManager().findById(processInstanceId);\n\n        if (processInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find process instance with id \" + processInstanceId, ExecutionEntity.class);\n        }\n\n        return processEngineConfiguration.getEntityLinkServiceConfiguration().getEntityLinkService()\n                .findEntityLinksByReferenceScopeIdAndType(processInstanceId, ScopeTypes.BPMN, EntityLinkType.CHILD);\n    }\n\n}\n","sourceCodeStart":29,"sourceCodeEnd":55,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetEntityLinkParentsForProcessInstanceCmd.java#L29-L55","documentation":"GetEntityLinkParentsForProcessInstanceCmd looks up the process instance and throws FlowableObjectNotFoundException if findById returns null. Parent entity links can only be resolved from an existing BPMN process instance scope.","triggerScenarios":"Calling RuntimeService.getEntityLinkParentsForProcessInstance(processInstanceId) when the id does not correspond to a live process instance execution.","commonSituations":"Querying after the instance ended; stale ids cached in an external app; id from a different engine database; mistyped id string.","solutions":["Guard the call with runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult() != null.","Use history entity-link queries once the process instance has completed.","Double-check you are passing the root process instance id, not a child execution id.","Verify engine/database configuration matches where the instance was started."],"exampleFix":"// before\nruntimeService.getEntityLinkParentsForProcessInstance(pid);\n// after\nif (runtimeService.createProcessInstanceQuery().processInstanceId(pid).count() > 0) {\n    runtimeService.getEntityLinkParentsForProcessInstance(pid);\n}","handlingStrategy":"validation","validationCode":"boolean exists = runtimeService.createProcessInstanceQuery()\n    .processInstanceId(processInstanceId).count() > 0;","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.getEntityLinkParentsForProcessInstance(id);\n} catch (FlowableObjectNotFoundException e) {\n    // handle missing instance (completed or wrong id)\n}","preventionTips":["Fetch instance ids from live query results only","Use historic entity-link queries post-completion","Avoid caching process instance ids long-term","Check datasource config in multi-engine setups"],"tags":["flowable","entity-link","process-instance","not-found"],"backgroundTag":"entity-not-found","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"}