{"record":{"id":"57a0ad852c4073fb","repo":"flowable/flowable-engine","slug":"task-57a0ad","errorCode":null,"errorMessage":"task ","messagePattern":"task ","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskDataObjectCmd.java","lineNumber":73,"sourceCode":"        this.variableName = variableName;\n        this.locale = locale;\n        this.withLocalizationFallback = withLocalizationFallback;\n    }\n\n    @Override\n    public DataObject 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        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        DataObject dataObject = null;\n        VariableInstance variableEntity = task.getVariableInstance(variableName, false);\n\n        String localizedName = null;\n        String localizedDescription = null;\n\n        if (variableEntity != null) {\n            ExecutionEntity executionEntity = CommandContextUtil.getExecutionEntityManager(commandContext).findById(variableEntity.getExecutionId());\n            while (!executionEntity.isScope()) {\n                executionEntity = executionEntity.getParent();\n            }\n\n            BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(executionEntity.getProcessDefinitionId());\n            ValuedDataObject foundDataObject = null;\n            if (executionEntity.getParentId() == null) {\n                for (ValuedDataObject dataObjectDefinition : bpmnModel.getMainProcess().getDataObjects()) {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskDataObjectCmd.java#L55-L91","documentation":"After validating inputs, GetTaskDataObjectCmd loads the task via TaskService.getTask(taskId). If no task exists for that id it throws FlowableObjectNotFoundException(\"task <id> doesn't exist\", Task.class), meaning the taskId is well-formed but references no live task.","triggerScenarios":"Calling taskService.getDataObject(taskId, variableName) with a taskId that was deleted, never existed, belongs to a different engine/database, or refers to a completed task removed by history cleanup.","commonSituations":"Stale task ids cached by the caller; task completed and deleted between lookup and variable read; querying against a test database while using ids from another environment; tenant/db mismatch in multi-engine setups.","solutions":["Verify the taskId is correct and exists via taskService.createTaskQuery().taskId(id).singleResult() before reading variables","Handle FlowableObjectNotFoundException in the caller and treat it as 'task gone' (e.g. re-fetch or inform the user)","Check you are connected to the same process engine/database that owns the task","If the task may legitimately disappear, catch the exception instead of letting it propagate"],"exampleFix":"// before\nDataObject d = taskService.getDataObject(taskId, variableName); // throws if task gone\n// after\nTask task = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (task != null) {\n    DataObject d = taskService.getDataObject(taskId, variableName);\n}","handlingStrategy":"try-catch","validationCode":"Task task = taskService.createTaskQuery().taskId(taskId).singleResult();\nboolean exists = task != null;","typeGuard":"boolean taskExists(String taskId) {\n    return taskId != null\n        && taskService.createTaskQuery().taskId(taskId).count() > 0;\n}","tryCatchPattern":"try {\n    DataObject d = taskService.getDataObject(taskId, variableName);\n} catch (FlowableObjectNotFoundException e) {\n    // task deleted/completed; treat as empty result\n    d = null;\n}","preventionTips":["Re-query the task instead of caching task ids long-term","Expect tasks to disappear on completion in shared engines","Confirm engine/database matches the environment of the taskId"],"tags":["java","flowable","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-14T11:17:12.474Z"}