{"record":{"id":"ee39a573917d024c","repo":"flowable/flowable-engine","slug":"historic-case-instance-caseinstanceid-variabl","errorCode":null,"errorMessage":"Historic case instance '${caseInstanceId}' variable value for ${variableName} couldn't be found.","messagePattern":"Historic case instance '(.+?)' variable value for (.+?) 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/caze/HistoricCaseInstanceVariableDataResource.java","lineNumber":100,"sourceCode":"            }\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 caseInstanceId, String variableName) {\n        HistoricCaseInstance caseObject = getHistoricCaseInstanceFromRequest(caseInstanceId);\n\n        HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery()\n                        .caseInstanceId(caseObject.getId())\n                        .variableName(variableName)\n                        .singleResult();\n\n        if (variable == null || variable.getValue() == null) {\n            throw new FlowableObjectNotFoundException(\"Historic case instance '\" + caseInstanceId + \"' variable value for \" + variableName + \" couldn't be found.\", VariableInstanceEntity.class);\n        } else {\n            return restResponseFactory.createRestVariable(variableName, variable.getValue(), null, caseInstanceId, CmmnRestResponseFactory.VARIABLE_HISTORY_CASE, includeBinary);\n        }\n    }\n}\n","sourceCodeStart":82,"sourceCodeEnd":106,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/history/caze/HistoricCaseInstanceVariableDataResource.java#L82-L106","documentation":"FlowableObjectNotFoundException thrown when a historic case instance variable (or its value) cannot be found by name for the given historic case instance. The query historyService.createHistoricVariableInstanceQuery() either returned no row or the stored value was null. The message embeds the caseInstanceId and variableName for diagnosis.","triggerScenarios":"GET /cmmn-history/historic-case-instances/{caseInstanceId}/variables/{variableName} (via the variable endpoint calling getVariableFromRequest) with a variableName that has no matching historic variable instance, or whose value is null (e.g. the variable was set to null before case completion).","commonSituations":"Typo in the variable name; querying a variable that was only ever null; case history not retained (history level too low); wrong caseInstanceId (no such historic case); variable scoped to a child plan item rather than the case.","solutions":["Verify the caseInstanceId exists: GET /cmmn-history/historic-case-instances/{caseInstanceId}.","List all historic variables via GET /cmmn-history/historic-case-instances/{caseInstanceId}/variables to confirm the exact name.","Catch FlowableObjectNotFoundException and return 404 to the client instead of letting it bubble as 500.","Check the engine's history level configuration includes variable history (historyLevel >= audit).","If the value was legitimately null, treat 'null value' as expected and handle it client-side."],"exampleFix":"// before\nRestVariable v = client.getHistoricCaseVariable(caseId, \"orderTotal\");\n// after\ntry {\n    RestVariable v = client.getHistoricCaseVariable(caseId, \"orderTotal\");\n} catch (FlowableObjectNotFoundException e) {\n    return ResponseEntity.notFound().build();\n}","handlingStrategy":"try-catch","validationCode":"// pre-check: GET /cmmn-history/historic-case-instances/{caseId}/variables\n// and confirm the variableName exists and value != null","typeGuard":null,"tryCatchPattern":"try {\n    RestVariable v = getHistoricCaseVariable(caseId, name);\n} catch (FlowableObjectNotFoundException e) {\n    return ResponseEntity.notFound().build();\n}","preventionTips":["List historic variables first instead of guessing names.","Remember null-valued variables are indistinguishable from missing ones here.","Ensure history level (audit/full) retains variable history.","Validate caseInstanceId before querying variables."],"tags":["flowable","rest","history","variable-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-14T05:17:10.506Z"}