{"record":{"id":"069e14b774953dbb","repo":"flowable/flowable-engine","slug":"task-taskid-doesn-t-exist-069e14","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/GetTaskVariablesCmd.java","lineNumber":57,"sourceCode":"    protected boolean isLocal;\n\n    public GetTaskVariablesCmd(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, Object> 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        if (variableNames == null) {\n\n            if (isLocal) {\n                return task.getVariablesLocal();\n            } else {\n                return task.getVariables();\n            }\n\n        } else {\n\n            if (isLocal) {\n                return task.getVariablesLocal(variableNames, false);\n            } else {\n                return task.getVariables(variableNames, false);\n            }\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariablesCmd.java#L39-L75","documentation":"GetTaskVariablesCmd loads the task entity before returning its variables. If the task service cannot find a task for the supplied taskId it throws FlowableObjectNotFoundException('task <id> doesn't exist', Task.class). Inputs are valid; the referenced task is gone or unknown.","triggerScenarios":"getVariables(taskId)/getVariablesLocal(taskId, ...) called with an id of a completed/deleted task, a task from another database or engine (BPMN vs CMMN), or a simply wrong/mistyped id.","commonSituations":"Human-task UI holding a stale id after the task was claimed and completed elsewhere; environment mismatch (prod id used against a dev engine); task purged by history cleanup jobs while the client still referenced it.","solutions":["Confirm the task exists via cmmnTaskService.createTaskQuery().taskId(id).singleResult() before reading variables.","Catch FlowableObjectNotFoundException and handle it as business 'task finished/unknown' logic.","Verify you are connected to the same database/tenant where the CMMN case created the task.","If the task completed, use CmmnHistoryService task variable queries instead."],"exampleFix":"// before\nMap<String, Object> vars = cmmnTaskService.getVariables(taskId);\n// after\ntry {\n    Map<String, Object> vars = cmmnTaskService.getVariables(taskId);\n} catch (FlowableObjectNotFoundException e) {\n    // task completed or unknown id - use history or return empty map\n    Map<String, Object> vars = Collections.emptyMap();\n}","handlingStrategy":"try-catch","validationCode":"Task task = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (task == null) { return Collections.emptyMap(); }","typeGuard":null,"tryCatchPattern":"try { return taskService.getVariables(taskId); } catch (FlowableObjectNotFoundException e) { // completed, deleted, or wrong engine\n    return Collections.emptyMap(); }","preventionTips":["Distinguish CMMN vs BPMN task services when reusing ids","Use history APIs after task completion","Avoid stale UI state: re-query before acting on a stored task id"],"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"}