{"record":{"id":"fbc16a5b4bdbbd68","repo":"flowable/flowable-engine","slug":"could-not-find-a-process-instance-with-id-pro-fbc16a","errorCode":null,"errorMessage":"Could not find a process instance with id '\" + processInstanceId + \"'.","messagePattern":"Could not find a process instance with id '\" \\+ processInstanceId \\+ \"'\\.","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/BaseProcessInstanceResource.java","lineNumber":395,"sourceCode":"     */\n    protected ProcessInstance getProcessInstanceFromRequest(String processInstanceId) {\n        ProcessInstance processInstance = getProcessInstanceFromRequestWithoutAccessCheck(processInstanceId);\n\n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessProcessInstanceInfoById(processInstance);\n        }\n\n        return processInstance;\n    }\n\n    /**\n     * Returns the {@link ProcessInstance} that is requested without calling the access interceptor\n     * Throws the right exceptions when bad request was made or instance was not found.\n     */\n    protected ProcessInstance getProcessInstanceFromRequestWithoutAccessCheck(String processInstanceId) {\n        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();\n        if (processInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find a process instance with id '\" + processInstanceId + \"'.\");\n        }\n        return processInstance;\n    }\n}\n","sourceCodeStart":377,"sourceCodeEnd":400,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/BaseProcessInstanceResource.java#L377-L400","documentation":"getProcessInstanceFromRequestWithoutAccessCheck queries runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult() and throws FlowableObjectNotFoundException when no running process instance matches the given id. Note it only sees running instances, not completed/historic ones.","triggerScenarios":"GET /runtime/process-instances/{processInstanceId} with an id that does not exist, was mistyped, or refers to a process instance that has already ended (only history retains those).","commonSituations":"Client cached an id of an instance that finished between calls; confusion between process instance id and business key or process definition id; querying a historic instance through the runtime endpoint instead of /history/historic-process-instances.","solutions":["Verify the processInstanceId exists via /runtime/process-instances list query","If the instance may have completed, query /history/historic-process-instances/{id} instead","Check that you are using the process instance id (e.g. '5001') and not the business key or definition id"],"exampleFix":"// before\nGET /runtime/process-instances/5001   // instance already completed -> 404\n// after\nGET /history/historic-process-instances/5001","handlingStrategy":"try-catch","validationCode":"const list = await api.get('/runtime/process-instances?processInstanceId=' + id); if (!list.data || list.data.length === 0) { /* fall back to history endpoint */ }","typeGuard":"function isNotFound(e) { return e && (e.status === 404 || e.message.includes('Could not find a process instance')); }","tryCatchPattern":"try { return await api.get('/runtime/process-instances/' + id); } catch (e) { if (e.status === 404) return await api.get('/history/historic-process-instances/' + id); throw e; }","preventionTips":["Distinguish runtime vs historic endpoints: runtime only has running instances","Never use the business key as the process instance id","Re-fetch instance lists rather than caching ids across long-running workflows"],"tags":["flowable","rest-api","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"}