{"record":{"id":"0a3445d45d5376b1","repo":"flowable/flowable-engine","slug":"historic-task-instance-variable-value-for-coul","errorCode":null,"errorMessage":"Historic task instance '' variable value for  couldn't be found.","messagePattern":"Historic task 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/task/HistoricTaskInstanceVariableDataResource.java","lineNumber":136,"sourceCode":"\n        Object value = null;\n        if (variableScope != null) {\n            if (variableScope == RestVariableScope.GLOBAL) {\n                value = taskObject.getProcessVariables().get(variableName);\n            } else {\n                value = taskObject.getTaskLocalVariables().get(variableName);\n            }\n        } else {\n            // look for local task variables first\n            if (taskObject.getTaskLocalVariables().containsKey(variableName)) {\n                value = taskObject.getTaskLocalVariables().get(variableName);\n            } else {\n                value = taskObject.getProcessVariables().get(variableName);\n            }\n        }\n\n        if (value == null) {\n            throw new FlowableObjectNotFoundException(\"Historic task instance '\" + taskId + \"' variable value for \" + variableName + \" couldn't be found.\", VariableInstanceEntity.class);\n        } else {\n            return restResponseFactory.createRestVariable(variableName, value, null, taskId, CmmnRestResponseFactory.VARIABLE_HISTORY_TASK, includeBinary);\n        }\n    }\n}\n","sourceCodeStart":118,"sourceCodeEnd":142,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/history/task/HistoricTaskInstanceVariableDataResource.java#L118-L142","documentation":"Thrown by the CMMN REST API when a historic task variable lookup returns nothing: GET history/historic-task-instances/{taskId}/variables/{variableName} resolved no variable with that name on the historic task instance. Flowable wraps this as FlowableObjectNotFoundException because the requested historic variable resource does not exist, so the endpoint returns a 404 with this message. It is a lookup miss, not a data corruption or permission issue.","triggerScenarios":"GET /cmmn-history/historic-task-instances/{taskId}/variables/{variableName} where the historic task exists but has no completed/persisted variable with that exact name, the variable was set and deleted before task completion, the taskId does not exist at all, or the variable name is misspelled / differs in case.","commonSituations":"Developers query a variable that only exists at runtime (set after the task finished), use the case-task variable name instead of the stored name, hit the CMMN history endpoint expecting process-engine semantics, or test against an in-memory H2 database that was recreated between calls so history is empty.","solutions":["Verify the taskId exists via GET /cmmn-history/historic-task-instances/{taskId} before fetching a variable.","List all variables first with GET /cmmn-history/historic-task-instances/{taskId}/variables and use an exact name from the response.","Check for typos/case differences in variableName; historic variable names are matched exactly.","Confirm the variable was actually set on the task before it completed (runtime variable set after completion never lands in history).","If the variable may legitimately be absent, catch FlowableObjectNotFoundException and treat it as an empty value instead of a failure."],"exampleFix":"// before: direct fetch that 404s on missing name\nRestVariable v = client.getHistoricTaskVariable(taskId, \"approver\");\n\n// after: tolerate absence\ntry {\n    RestVariable v = client.getHistoricTaskVariable(taskId, \"approver\");\n} catch (FlowableObjectNotFoundException e) {\n    String approver = null; // variable not in history\n}","handlingStrategy":"try-catch","validationCode":"// resolve and check first\nHistoricTaskInstance t = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();\nif (t == null || t.getProcessVariables() == null || !t.getProcessVariables().containsKey(variableName)) {\n    // skip the variable fetch or use a default\n}","typeGuard":"boolean hasHistoricVariable(HistoricTaskInstance t, String name) {\n    return t != null && t.getVariables() != null && t.getVariables().containsKey(name);\n}","tryCatchPattern":"try {\n    RestVariable v = resource.getVariable(taskId, variableName);\n} catch (FlowableObjectNotFoundException e) {\n    // HTTP 404: variable not present in history; use default/null\n}","preventionTips":["List all task variables before requesting a specific one","Match variable names exactly (case-sensitive)","Verify taskId exists before variable lookup","Remember runtime-only variables set after completion never appear in history"],"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"}