{"record":{"id":"f2fa938614692d74","repo":"flowable/flowable-engine","slug":"task-taskid-doesn-t-exist","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/GetTaskVariableCmd.java","lineNumber":57,"sourceCode":"        this.taskId = taskId;\n        this.variableName = variableName;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public Object 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        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        Object value;\n\n        if (isLocal) {\n            value = task.getVariableLocal(variableName, false);\n        } else {\n            value = task.getVariable(variableName, false);\n        }\n\n        return value;\n    }\n}\n","sourceCodeStart":39,"sourceCodeEnd":71,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariableCmd.java#L39-L71","documentation":"GetTaskVariableCmd throws FlowableObjectNotFoundException (with Task.class) when the task service returns no TaskEntity for the given taskId. The variable lookup cannot proceed without an existing task.","triggerScenarios":"Calling cmmnTaskService.getVariable(taskId, name) with a taskId that has no matching CMMN task — wrong id, task completed and moved to history, or id from the BPMN engine instead of CMMN.","commonSituations":"Cross-engine id confusion (BPMN taskService vs cmmnTaskService); querying after the case/task was terminated and removed; stale ids cached in an external UI across environment switches.","solutions":["Verify existence first: cmmnTaskService.createTaskQuery().taskId(taskId).singleResult()","For completed tasks use cmmnHistoryService.createHistoricTaskInstanceQuery() and historic variable queries","Make sure the id comes from the CMMN engine's task service, not the BPMN one","Handle the FlowableObjectNotFoundException in callers that accept user-supplied task ids"],"exampleFix":"// before\nObject value = cmmnTaskService.getVariable(taskId, varName); // throws if task gone\n// after\nTask t = cmmnTaskService.createTaskQuery().taskId(taskId).singleResult();\nObject value = (t != null)\n    ? cmmnTaskService.getVariable(taskId, varName)\n    : cmmnHistoryService.createHistoricVariableInstanceQuery().taskId(taskId).variableName(varName).singleValue();","handlingStrategy":"try-catch","validationCode":"Task t = cmmnTaskService.createTaskQuery().taskId(taskId).singleResult();\nif (t == null) {\n    throw new IllegalArgumentException(\"No CMMN task for id \" + taskId);\n}","typeGuard":"boolean taskExists(String taskId) {\n    return taskId != null && cmmnTaskService.createTaskQuery().taskId(taskId).count() > 0;\n}","tryCatchPattern":"try {\n    Object value = cmmnTaskService.getVariable(taskId, variableName);\n} catch (FlowableObjectNotFoundException e) {\n    // Task.class entity missing: fall back to historic variable query or return 404\n}","preventionTips":["Check task existence with a query before variable reads on user-supplied ids","Route completed tasks to historic variable queries","Keep CMMN and BPMN task id namespaces separate in clients"],"tags":["cmmn","tasks","not-found"],"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"}