{"record":{"id":"8eeb0dd041462c1a","repo":"flowable/flowable-engine","slug":"task-taskid-doesn-t-exist-8eeb0d","errorCode":null,"errorMessage":"task ${taskId} doesn't exist","messagePattern":"task (.+?) doesn't exist","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariableInstancesCmd.java","lineNumber":54,"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        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        TaskEntity task = cmmnEngineConfiguration.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":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariableInstancesCmd.java#L36-L72","documentation":"GetTaskVariableInstancesCmd fetches the task entity before reading its variable instances. When the task service returns no task for the given taskId, the command throws FlowableObjectNotFoundException('task <id> doesn't exist', Task.class): the id is well-formed but references a task that no longer exists.","triggerScenarios":"Calling getVariableInstances(taskId)/getVariableInstancesLocal(taskId, names) where the task was completed/removed, the case instance was deleted, or the id never existed in this engine's database.","commonSituations":"Racing with task completion in another thread/node; stale ids stored in an external table; pointing a client at a test/prod database mismatch; referencing a task from an aborted case instance.","solutions":["Re-validate task existence with createTaskQuery().taskId(id).singleResult() before fetching variables.","Catch FlowableObjectNotFoundException and fall back to history APIs if the task may have finished.","Confirm the engine configuration (datasource, tenant) matches where the task was created.","Avoid caching task ids across long-running operations; resolve them fresh at use time."],"exampleFix":"// before\nMap<String, VariableInstance> vars = cmmnTaskService.getVariableInstances(taskId);\n// after\nTask task = cmmnTaskService.createTaskQuery().taskId(taskId).singleResult();\nif (task == null) {\n    throw new IllegalStateException(\"Task \" + taskId + \" no longer exists\");\n}\nMap<String, VariableInstance> vars = cmmnTaskService.getVariableInstances(taskId);","handlingStrategy":"try-catch","validationCode":"if (taskService.createTaskQuery().taskId(taskId).count() == 0) { return Collections.emptyMap(); }","typeGuard":null,"tryCatchPattern":"try { return taskService.getVariableInstances(taskId); } catch (FlowableObjectNotFoundException e) { return Collections.emptyMap(); }","preventionTips":["Don't hold task ids across transactions that may complete the task","Handle concurrent completion gracefully (empty map is a valid answer)","Check that test/prod environments point at the intended database"],"tags":["flowable","cmmn","entity-not-found","task"],"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"}