{"record":{"id":"353b5231719763da","repo":"flowable/flowable-engine","slug":"task-taskid-doesn-t-exist-353b52","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/GetTaskVariableInstancesCmd.java","lineNumber":53,"sourceCode":"    protected boolean isLocal;\n\n    public GetTaskVariableInstancesCmd(String taskId, Collection<String> variableNames, boolean isLocal) {\n        this.taskId = taskId;\n        this.variableNames = variableNames;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public Map<String, VariableInstance> execute(CommandContext commandContext) {\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId 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        Map<String, VariableInstance> variables = null;\n        if (variableNames == null) {\n\n            if (isLocal) {\n                variables = task.getVariableInstancesLocal();\n            } else {\n                variables = task.getVariableInstances();\n            }\n\n        } else {\n            if (isLocal) {\n                variables = task.getVariableInstancesLocal(variableNames, false);\n            } else {\n                variables = task.getVariableInstances(variableNames, false);\n            }\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskVariableInstancesCmd.java#L35-L71","documentation":"FlowableObjectNotFoundException (Task.class) thrown by GetTaskVariableInstancesCmd.execute when no task exists for the given taskId. The lookup via the task service returns null and the command aborts before assembling the variables map; the variableNames/isLocal parameters are never consulted.","triggerScenarios":"taskService.getTaskVariableInstances(taskId) with an id for a task that never existed, was deleted, was completed with runtime data cleared, or lives in another database/tenant; filtering with a variableNames list cannot rescue a missing task.","commonSituations":"Polling job still processing a task id after process termination; cluster nodes sharing a load balancer but not the same engine database; tests reusing ids from a truncated schema.","solutions":["Existence-check with taskService.createTaskQuery().taskId(taskId).count() before fetching variables","Confirm all nodes/environments point at the shared engine database","For completed tasks, use historyService.createHistoricTaskInstanceQuery / HistoricVariableInstanceQuery","Catch FlowableObjectNotFoundException and return an idempotent not-found result in batch workers"],"exampleFix":"// before\nMap<String, VariableInstance> vars = taskService.getTaskVariableInstances(taskId);\n// after\nif (taskService.createTaskQuery().taskId(taskId).count() == 0) {\n    return Collections.emptyMap(); // or throw domain-specific NotFound\n}\nMap<String, VariableInstance> vars = taskService.getTaskVariableInstances(taskId);","handlingStrategy":"try-catch","validationCode":"boolean exists = taskService.createTaskQuery().taskId(taskId).count() > 0;","typeGuard":null,"tryCatchPattern":"try {\n    Map<String, VariableInstance> vars = taskService.getTaskVariableInstances(taskId);\n} catch (FlowableObjectNotFoundException e) {\n    respond(404, \"Task \" + taskId + \" does not exist\");\n}","preventionTips":["Existence-check tasks before fetching variable maps","Design idempotent workers that tolerate vanished tasks","Keep all environments on the same engine database/schema"],"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"}