{"record":{"id":"54e55a00b10b0a21","repo":"flowable/flowable-engine","slug":"cannot-find-process-instance-with-id-54e55a","errorCode":null,"errorMessage":"Cannot find process instance with id ","messagePattern":"Cannot find process instance with id ","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetIdentityLinksForProcessInstanceCmd.java","lineNumber":44,"sourceCode":" * @author Marcus Klimstra\n */\npublic class GetIdentityLinksForProcessInstanceCmd implements Command<List<IdentityLink>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String processInstanceId;\n\n    public GetIdentityLinksForProcessInstanceCmd(String processInstanceId) {\n        this.processInstanceId = processInstanceId;\n    }\n\n    @SuppressWarnings({ \"unchecked\", \"rawtypes\" })\n    @Override\n    public List<IdentityLink> execute(CommandContext commandContext) {\n        ExecutionEntity processInstance = CommandContextUtil.getExecutionEntityManager(commandContext).findById(processInstanceId);\n\n        if (processInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find process instance with id \" + processInstanceId, ExecutionEntity.class);\n        }\n\n        return (List) processInstance.getIdentityLinks();\n    }\n\n}\n","sourceCodeStart":26,"sourceCodeEnd":51,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetIdentityLinksForProcessInstanceCmd.java#L26-L51","documentation":"GetIdentityLinksForProcessInstanceCmd.execute fetches the process instance (ExecutionEntity) by id and throws FlowableObjectNotFoundException if findById returns null. Identity links on a process instance are stored with the execution, so a missing execution means no links can be returned. Throwing here prevents a NullPointerException on processInstance.getIdentityLinks().","triggerScenarios":"Calling RuntimeService.getIdentityLinksForProcessInstance(processInstanceId) with an id for an instance that already ended (and was removed from runtime tables), was deleted, or never existed in the connected database.","commonSituations":"Looking up links for a completed process instance (moved to history, gone from ACT_RU_EXECUTION); id captured before an async completion/cleanup job ran; cross-environment id reuse; passing a historic process instance id into the runtime API.","solutions":["If the instance may have completed, use historyService.createHistoricProcessInstanceQuery().processInstanceId(id) to confirm it ended","Fetch identity links from history APIs for finished instances instead of RuntimeService","Validate the id is an active runtime instance: runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult()","Check you are on the correct database/environment for the id","Catch FlowableObjectNotFoundException and treat the instance as gone"],"exampleFix":"// before\nList<IdentityLink> links = runtimeService.getIdentityLinksForProcessInstance(pid);\n// after\nif (runtimeService.createProcessInstanceQuery().processInstanceId(pid).count() == 0) {\n    throw new IllegalStateException(\"Process instance not active: \" + pid);\n}\nList<IdentityLink> links = runtimeService.getIdentityLinksForProcessInstance(pid);","handlingStrategy":"try-catch","validationCode":"boolean active = runtimeService.createProcessInstanceQuery().processInstanceId(pid).count() > 0;","typeGuard":null,"tryCatchPattern":"try {\n  List<IdentityLink> links = runtimeService.getIdentityLinksForProcessInstance(pid);\n} catch (FlowableObjectNotFoundException e) {\n  // instance ended or never existed; fall back to history queries\n  links = Collections.emptyList();\n}","preventionTips":["Only query runtime identity links for instances still in ACT_RU_EXECUTION","For finished instances use the history service instead","Avoid caching process instance ids across long-lived UI sessions","Verify datasource/environment consistency"],"tags":["flowable","process-instance","not-found","runtime"],"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"}