{"record":{"id":"e0db3c99b27aaf88","repo":"flowable/flowable-engine","slug":"cannot-find-task-with-id-taskid-e0db3c","errorCode":null,"errorMessage":"Cannot find task with id ${taskId}","messagePattern":"Cannot find task with id (.+?)","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetEntityLinkParentsForTaskCmd.java","lineNumber":51,"sourceCode":"public class GetEntityLinkParentsForTaskCmd implements Command<List<EntityLink>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String taskId;\n\n    public GetEntityLinkParentsForTaskCmd(String taskId) {\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is required\");\n        }\n        this.taskId = taskId;\n    }\n\n    @Override\n    public List<EntityLink> execute(CommandContext commandContext) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        TaskEntity task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);\n\n        if (task == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find task with id \" + taskId, ExecutionEntity.class);\n        }\n\n        return processEngineConfiguration.getEntityLinkServiceConfiguration().getEntityLinkService()\n                .findEntityLinksByReferenceScopeIdAndType(task.getId(), ScopeTypes.TASK, EntityLinkType.CHILD);\n    }\n\n}\n","sourceCodeStart":33,"sourceCodeEnd":59,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetEntityLinkParentsForTaskCmd.java#L33-L59","documentation":"GetEntityLinkParentsForTaskCmd.execute() fetches the task via the task service and throws FlowableObjectNotFoundException when no task exists for taskId. Note the entity type is passed as ExecutionEntity.class, a quirk of the implementation, but semantically the missing entity is the task.","triggerScenarios":"Calling TaskService.getEntityLinkParentsForTask(taskId) (or executing the command) with a task id that does not exist or whose task has been completed and removed.","commonSituations":"Using a historic/completed task id against the runtime task service; stale ids after standalone task deletion; cross-database id; passing a scope/execution id instead of a task id.","solutions":["Verify the task exists first: taskService.createTaskQuery().taskId(id).count() > 0.","For completed tasks use HistoryService historic task entity-link queries.","Validate the id is actually a task id from TaskEntity.getId() or task responses.","Ensure the engine connects to the database that owns the task."],"exampleFix":"// before\ntaskService.getEntityLinkParentsForTask(taskId);\n// after\nif (taskService.createTaskQuery().taskId(taskId).count() > 0) {\n    taskService.getEntityLinkParentsForTask(taskId);\n} else {\n    // fall back to history for completed tasks\n}","handlingStrategy":"validation","validationCode":"boolean exists = taskService.createTaskQuery().taskId(taskId).count() > 0;","typeGuard":null,"tryCatchPattern":"try {\n    taskService.getEntityLinkParentsForTask(taskId);\n} catch (FlowableObjectNotFoundException e) {\n    // task completed/deleted: fall back to history queries\n}","preventionTips":["Verify task existence before runtime lookups","Use history service for completed tasks","Take ids from TaskEntity.getId() or task API responses","Confirm single database across services"],"tags":["flowable","task","entity-link","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"}