{"record":{"id":"c25b45e77c190b72","repo":"flowable/flowable-engine","slug":"task-taskid-doesn-t-exist-c25b45","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/GetTaskVariableInstanceCmd.java","lineNumber":55,"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        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        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":37,"sourceCodeEnd":69,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariableInstanceCmd.java#L37-L69","documentation":"After validating inputs, GetTaskVariableInstanceCmd looks up the task via the task service. If no task with the given taskId exists (it was completed, deleted, or the id is wrong), it throws FlowableObjectNotFoundException('task <id> doesn't exist', Task.class). The id is syntactically fine but points at no existing CMMN task entity.","triggerScenarios":"Calling getVariableInstance/getVariableInstanceLocal with a taskId for a task that has been completed and removed, deleted via taskService.deleteTask, or never existed (wrong id, wrong engine/database).","commonSituations":"Stale task id cached in a client after task completion; querying a different database/schema than the one the case ran in; deleted case instance whose tasks were removed; id copied from a BPMN task used against the CMMN engine.","solutions":["Verify the taskId is current: re-query cmmnTaskService.createTaskQuery().taskId(id).singleResult() before fetching variables.","Check the engine/database configuration points at the same datasource the task was created in.","Wrap the call in try/catch for FlowableObjectNotFoundException and treat it as task-not-found rather than a bug.","If the task was completed, read variables from history services (e.g. history query APIs) instead of the runtime task."],"exampleFix":"// before\nVariableInstance vi = cmmnTaskService.getVariableInstance(taskId, varName);\n// after\nTask task = cmmnTaskService.createTaskQuery().taskId(taskId).singleResult();\nif (task == null) {\n    // task finished or wrong id - fall back to history or abort\n    return null;\n}\nVariableInstance vi = cmmnTaskService.getVariableInstance(taskId, varName);","handlingStrategy":"try-catch","validationCode":"Task t = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (t == null) { /* not found: skip or use history */ }","typeGuard":null,"tryCatchPattern":"try { return taskService.getVariableInstance(taskId, name); } catch (FlowableObjectNotFoundException e) { log.info(\"Task {} not found, may be completed\", taskId); return null; }","preventionTips":["Re-fetch tasks fresh instead of caching ids across operations","Fall back to CmmnHistoryService for completed tasks","Verify datasource/tenant configuration matches where the case ran"],"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"}