{"record":{"id":"9747ca1784f7fb7e","repo":"flowable/flowable-engine","slug":"historic-variable-instance-couldn-t-be-found","errorCode":null,"errorMessage":"Historic variable instance '' couldn't be found.","messagePattern":"Historic variable instance '' couldn't be found\\.","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/history/variable/HistoricVariableInstanceBaseResource.java","lineNumber":107,"sourceCode":"        }\n\n        if (queryRequest.getVariables() != null) {\n            addVariables(query, queryRequest.getVariables());\n        }\n        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessHistoryVariableInfoWithQuery(query, queryRequest);\n        }\n\n        return paginateList(allRequestParams, queryRequest, query, \"variableName\", allowedSortProperties,\n                restResponseFactory::createHistoricVariableInstanceResponseList);\n    }\n    \n    public RestVariable getVariableFromRequest(boolean includeBinary, String varInstanceId) {\n        HistoricVariableInstance varObject = historyService.createHistoricVariableInstanceQuery().id(varInstanceId).singleResult();\n\n        if (varObject == null) {\n            throw new FlowableObjectNotFoundException(\"Historic variable instance '\" + varInstanceId + \"' couldn't be found.\", VariableInstanceEntity.class);\n        } else {\n            if (restApiInterceptor != null) {\n                restApiInterceptor.accessHistoryVariableInfoById(varObject);\n            }\n            return restResponseFactory.createRestVariable(varObject.getVariableName(), varObject.getValue(), null, varInstanceId, CmmnRestResponseFactory.VARIABLE_HISTORY_VARINSTANCE, includeBinary);\n        }\n    }\n\n    protected void addVariables(HistoricVariableInstanceQuery variableInstanceQuery, List<QueryVariable> variables) {\n        for (QueryVariable variable : variables) {\n            if (variable.getVariableOperation() == null) {\n                throw new FlowableIllegalArgumentException(\"Variable operation is missing for variable: \" + variable.getName());\n            }\n            if (variable.getValue() == null) {\n                throw new FlowableIllegalArgumentException(\"Variable value is missing for variable: \" + variable.getName());\n            }\n\n            boolean nameLess = variable.getName() == null;","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/history/variable/HistoricVariableInstanceBaseResource.java#L89-L125","documentation":"Thrown by the CMMN REST API when querying a historic variable instance by its unique id: historyService.createHistoricVariableInstanceQuery().id(varInstanceId).singleResult() returned null, so no historic variable instance with that id exists. The resource rethrows it as FlowableObjectNotFoundException and the REST layer maps it to HTTP 404. It is a pure id-lookup miss on the ACT_HI_VARINST table.","triggerScenarios":"GET /cmmn-history/historic-variable-instances/{varInstanceId} with an id that was never created, an id from a different engine/database, an id belonging to runtime variables only (ACT_RU_VARINST, never archived to history), or after history cleanup/level 0 history config removed the row.","commonSituations":"Clients cache variable instance ids across database resets or test runs, ids are copied from a process-engine (BPMN) deployment while querying the CMMN history API, or history level is set to none/activity so variable instances are never written to history.","solutions":["Verify the varInstanceId by querying historyService.createHistoricVariableInstanceQuery().list() (or the REST list endpoint) and confirm the id exists.","Check that history level is at least 'audit' so variable instances are persisted to ACT_HI_VARINST.","Confirm you are pointing at the same database/engine that produced the id (CMMN vs BPMN, test vs prod).","If the id may be stale, re-resolve it by variableName/taskId instead of a hardcoded id.","Catch FlowableObjectNotFoundException on this endpoint when absence is an expected outcome."],"exampleFix":"// before\nRestVariable v = client.getHistoricVariableInstance(varInstanceId);\n\n// after\ntry {\n    RestVariable v = client.getHistoricVariableInstance(varInstanceId);\n} catch (FlowableObjectNotFoundException e) {\n    // fall back to lookup by name\n    v = findByName(variableName);\n}","handlingStrategy":"try-catch","validationCode":"HistoricVariableInstance v = historyService.createHistoricVariableInstanceQuery().id(varInstanceId).singleResult();\nif (v == null) { /* resolve id before calling the REST endpoint */ }","typeGuard":null,"tryCatchPattern":"try {\n    RestVariable v = resource.getVariable(varInstanceId);\n} catch (FlowableObjectNotFoundException e) {\n    // HTTP 404: no historic variable instance with this id\n}","preventionTips":["Do not hardcode variable instance ids; resolve them per environment","Ensure history level is audit (or higher) so ACT_HI_VARINST is populated","Distinguish CMMN vs BPMN history ids","Re-resolve ids by name/taskId after DB resets or history cleanup"],"tags":["rest-api","flowable","not-found","history"],"backgroundTag":"record-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"}