{"record":{"id":"d2cc813d64fc5f2c","repo":"flowable/flowable-engine","slug":"historic-task-instance-couldn-t-be-found","errorCode":null,"errorMessage":"Historic task instance '' couldn't be found.","messagePattern":"Historic task 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/task/HistoricTaskInstanceVariableDataResource.java","lineNumber":112,"sourceCode":"\n    public RestVariable getVariableFromRequest(boolean includeBinary, String taskId, String variableName, String scope) {\n        RestVariableScope variableScope = RestVariable.getScopeFromString(scope);\n        HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery().taskId(taskId);\n\n        if (variableScope != null) {\n            if (variableScope == RestVariableScope.GLOBAL) {\n                taskQuery.includeProcessVariables();\n            } else {\n                taskQuery.includeTaskLocalVariables();\n            }\n        } else {\n            taskQuery.includeTaskLocalVariables().includeProcessVariables();\n        }\n\n        HistoricTaskInstance taskObject = taskQuery.singleResult();\n\n        if (taskObject == null) {\n            throw new FlowableObjectNotFoundException(\"Historic task instance '\" + taskId + \"' couldn't be found.\", HistoricTaskInstanceEntity.class);\n        }\n        \n        if (restApiInterceptor != null) {\n            restApiInterceptor.accessHistoryTaskInfoById(taskObject);\n        }\n\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 {","sourceCodeStart":94,"sourceCodeEnd":130,"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#L94-L130","documentation":"FlowableObjectNotFoundException thrown when the historic task instance query by taskId plus optional scope filter returns no result. The variable endpoints first load the owning historic task via historyService.createHistoricTaskInstanceQuery().taskId(taskId); a null singleResult means the taskId is unknown, the task history was deleted, or scope filtering (task/process/global) excluded it.","triggerScenarios":"GET /cmmn-history/historic-task-instances/{taskId}/variables/{variableName} (or /data) with a nonexistent taskId, a taskId from a purged/cleaned-up history, or a 'scope' query parameter that doesn't match where the variable lives so include-flags hide it.","commonSituations":"Typos or wrong-ID prefixes (using a runtime task id after history cleanup, or a processInstanceId instead of taskId); history level configured below 'audit' so nothing was persisted; history cleanup job removed the task before the variable was fetched.","solutions":["Verify the taskId exists: GET /cmmn-history/historic-task-instances/{taskId} should return 200 before requesting variables","Check the scope query parameter — omit it or use the correct scope (task/local vs process/global) so the query includes the right variable set","Confirm history is persisted: historyLevel must be at least 'audit' and history cleanup must not have purged the task","If using the REST API against a different deployment/database, confirm you are querying the same Flowable instance that executed the task"],"exampleFix":"// before\nRestVariable v = get(taskId, varName); // 404 when taskId wrong\n// after\nHistoricTaskInstance t = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();\nif (t == null) throw new IllegalArgumentException(\"unknown historic task \" + taskId);\nRestVariable v = get(taskId, varName);","handlingStrategy":"validation","validationCode":"const task = await fetch(`/cmmn-history/historic-task-instances/${taskId}`);\nif (task.status === 404) throw new Error(`Historic task ${taskId} not found`);\n// only then fetch variables","typeGuard":"async function historicTaskExists(taskId) {\n  const res = await fetch(`/cmmn-history/historic-task-instances/${taskId}`);\n  return res.ok;\n}","tryCatchPattern":"try {\n  return await fetchVariable(taskId, name);\n} catch (e) {\n  if (/Historic task instance '.*' couldn't be found/.test(String(e.message))) {\n    throw new NotFoundError(`Historic task ${taskId} missing (purged or wrong id)`);\n  }\n  throw e;\n}","preventionTips":["Resolve the taskId from the task-creation response and store it, rather than reconstructing it","Confirm history level is 'audit' or higher so variables are persisted","Check history cleanup settings — a purged task yields 404 on all variable endpoints","Omit or correctly set the scope query parameter so the variable include-flags match"],"tags":["rest","historical-data","variables","resource-not-found"],"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-14T11:17:12.474Z"}