{"record":{"id":"1b5660964cf97340","repo":"flowable/flowable-engine","slug":"historic-process-instance-processinstanceid","errorCode":null,"errorMessage":"Historic process instance '\" + processInstanceId + \"' could not be found.","messagePattern":"Historic process instance '\" \\+ processInstanceId \\+ \"' could not be found\\.","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/history/HistoricProcessInstanceVariableDataResource.java","lineNumber":96,"sourceCode":"                response.setContentType(\"application/x-java-serialized-object\");\n\n            } else {\n                throw new FlowableObjectNotFoundException(\"The variable does not have a binary data stream.\", null);\n            }\n            return result;\n\n        } catch (IOException ioe) {\n            // Re-throw IOException\n            throw new FlowableException(\"Unexpected exception getting variable data\", ioe);\n        }\n    }\n\n    public RestVariable getVariableFromRequest(boolean includeBinary, String processInstanceId, String variableName) {\n\n        HistoricProcessInstance processObject = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().singleResult();\n\n        if (processObject == null) {\n            throw new FlowableObjectNotFoundException(\"Historic process instance '\" + processInstanceId + \"' could not be found.\", HistoricProcessInstanceEntity.class);\n        }\n        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessHistoryProcessInfoById(processObject);\n        }\n\n        Object value = processObject.getProcessVariables().get(variableName);\n\n        if (value == null) {\n            throw new FlowableObjectNotFoundException(\"Historic process instance '\" + processInstanceId + \"' variable value for \" + variableName + \" could not be found.\", VariableInstanceEntity.class);\n        } else {\n            return restResponseFactory.createRestVariable(variableName, value, null, processInstanceId, RestResponseFactory.VARIABLE_HISTORY_PROCESS, includeBinary);\n        }\n    }\n}\n","sourceCodeStart":78,"sourceCodeEnd":112,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/history/HistoricProcessInstanceVariableDataResource.java#L78-L112","documentation":"Flowable's historic process instance REST resource throws FlowableObjectNotFoundException when a query by processInstanceId finds no historic process instance. The historyService query returned no row, so the requested historic instance (or its id) does not exist in the ACT_HI_PROCINST table. The exception carries HistoricProcessInstanceEntity.class as the resolved resource type.","triggerScenarios":"Calling GET on the history process-instance variable endpoint (e.g. /history/historic-process-instances/{processInstanceId}/variables/{variableName}) via getVariableFromRequest with a processInstanceId that has no historic process instance row.","commonSituations":"Typo or wrong-case instance id; querying a still-running process (only completed/moved-to-history instances appear); history level configured too low (e.g. 'none'/'activity') so no instance rows are written; cleanup/job purged the history row; querying the wrong engine datasource.","solutions":["Verify the processInstanceId exists: query ACT_HI_PROCINST or call historyService.createHistoricProcessInstanceQuery().processInstanceId(id).singleResult() first","If the process is still running, use the runtime API (RuntimeService/ProcessInstanceQuery) instead of the history API","Check the engine's history level configuration; raise it (at least 'activity' or 'audit') so historic instances are recorded","Check whether history cleanup job removed the row and use a backup/copy if needed"],"exampleFix":"// before\nHistoricProcessInstance p = historyService.createHistoricProcessInstanceQuery().processInstanceId(id).singleResult();\nRestVariable v = getVariableFromRequest(true, id, name); // throws if p == null\n// after\nHistoricProcessInstance p = historyService.createHistoricProcessInstanceQuery().processInstanceId(id).singleResult();\nif (p == null) {\n    // handle missing history gracefully\n    return fallbackResponse(id);\n}\nRestVariable v = getVariableFromRequest(true, id, name);","handlingStrategy":"try-catch","validationCode":"HistoricProcessInstance p = historyService.createHistoricProcessInstanceQuery()\n    .processInstanceId(processInstanceId).singleResult();\nif (p == null) { throw new IllegalArgumentException(\"Unknown historic instance: \" + processInstanceId); }","typeGuard":null,"tryCatchPattern":"try { RestVariable v = rest.get(...); }\ncatch (FlowableObjectNotFoundException e) {\n    if (HistoricProcessInstanceEntity.class.equals(e.getObjectClass())) { /* handle missing history */ }\n    else throw e;\n}","preventionTips":["Verify ids against the history query before calling the REST endpoint","Remember history contains only finished/moved instances; use runtime API for live ones","Confirm history level is 'audit' or higher in flowable config"],"tags":["rest-api","history","not-found","flowable"],"backgroundTag":"resource-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}