{"record":{"id":"f3ff6911f5f76b79","repo":"flowable/flowable-engine","slug":"task-taskid-doesn-t-exist-f3ff69","errorCode":null,"errorMessage":"task \" + taskId + \" doesn't exist","messagePattern":"task \" \\+ taskId \\+ \" doesn't exist","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskVariableInstanceCmd.java","lineNumber":54,"sourceCode":"        this.taskId = taskId;\n        this.variableName = variableName;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public VariableInstance execute(CommandContext commandContext) {\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is null\");\n        }\n        if (variableName == null) {\n            throw new FlowableIllegalArgumentException(\"variableName is null\");\n        }\n\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        TaskEntity task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);\n\n        if (task == null) {\n            throw new FlowableObjectNotFoundException(\"task \" + taskId + \" doesn't exist\", Task.class);\n        }\n\n        VariableInstance variableEntity;\n\n        if (isLocal) {\n            variableEntity = task.getVariableInstanceLocal(variableName, false);\n        } else {\n            variableEntity = task.getVariableInstance(variableName, false);\n        }\n\n        return variableEntity;\n    }\n}\n","sourceCodeStart":36,"sourceCodeEnd":68,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskVariableInstanceCmd.java#L36-L68","documentation":"FlowableObjectNotFoundException (Task.class) thrown by GetTaskVariableInstanceCmd.execute when the task lookup returns null for the supplied taskId. The command fails before attempting to read any variable instance, so the error always means the task id is unresolvable, not that the variable is missing.","triggerScenarios":"taskService.getTaskVariableInstance(taskId, name) or getTaskVariableInstanceLocal with a nonexistent/stale/foreign-database taskId; task completed and removed between query and fetch.","commonSituations":"UI refreshing variable panels after a task was completed in another session; data migration gaps; ids from archived processes with history level 'none'.","solutions":["Check task existence via a task query before reading variables","Verify DB connectivity/schema and tenant filtering — id may exist in another datasource","Catch FlowableObjectNotFoundException and present a 'task no longer available' message","Read historical variables via historyService.createHistoricVariableInstanceQuery().taskId(...) if the task is finished"],"exampleFix":"// before\nVariableInstance vi = taskService.getTaskVariableInstance(taskId, name);\n// after\nTask t = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (t == null) {\n    return historyService.createHistoricVariableInstanceQuery().taskId(taskId).variableName(name).singleResult();\n}\nVariableInstance vi = taskService.getTaskVariableInstance(taskId, name);","handlingStrategy":"try-catch","validationCode":"boolean exists = taskService.createTaskQuery().taskId(taskId).count() > 0;","typeGuard":null,"tryCatchPattern":"try {\n    VariableInstance vi = taskService.getTaskVariableInstance(taskId, name);\n} catch (FlowableObjectNotFoundException e) {\n    respond(404, \"Task \" + taskId + \" not found\");\n}","preventionTips":["Check task existence before variable reads","Use historic variable queries for finished tasks","Share one engine database across all app nodes"],"tags":["flowable","task-not-found","variables"],"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-18T11:17:12.947Z"}