flowable/flowable-engine · error · FlowableObjectNotFoundException

Cannot find task with id

Error message

Cannot find task with id ${taskId}

What it means

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.

Solutions

  1. Verify the task exists first: taskService.createTaskQuery().taskId(id).count() > 0.
  2. For completed tasks use HistoryService historic task entity-link queries.
  3. Validate the id is actually a task id from TaskEntity.getId() or task responses.
  4. Ensure the engine connects to the database that owns the task.

Example fix

// before
taskService.getEntityLinkParentsForTask(taskId);
// after
if (taskService.createTaskQuery().taskId(taskId).count() > 0) {
    taskService.getEntityLinkParentsForTask(taskId);
} else {
    // fall back to history for completed tasks
}
Defensive patterns

Strategy: validation

Validate before calling

boolean exists = taskService.createTaskQuery().taskId(taskId).count() > 0;

Try / catch

try {
    taskService.getEntityLinkParentsForTask(taskId);
} catch (FlowableObjectNotFoundException e) {
    // task completed/deleted: fall back to history queries
}

Prevention

When it happens

Trigger: Calling TaskService.getEntityLinkParentsForTask(taskId) (or executing the command) with a task id that does not exist or whose task has been completed and removed.

Common situations: 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.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/e0db3c99b27aaf88. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetEntityLinkParentsForTaskCmd.java:51

public class GetEntityLinkParentsForTaskCmd implements Command<List<EntityLink>>, Serializable {

    private static final long serialVersionUID = 1L;
    protected String taskId;

    public GetEntityLinkParentsForTaskCmd(String taskId) {
        if (taskId == null) {
            throw new FlowableIllegalArgumentException("taskId is required");
        }
        this.taskId = taskId;
    }

    @Override
    public List<EntityLink> execute(CommandContext commandContext) {
        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
        TaskEntity task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);

        if (task == null) {
            throw new FlowableObjectNotFoundException("Cannot find task with id " + taskId, ExecutionEntity.class);
        }

        return processEngineConfiguration.getEntityLinkServiceConfiguration().getEntityLinkService()
                .findEntityLinksByReferenceScopeIdAndType(task.getId(), ScopeTypes.TASK, EntityLinkType.CHILD);
    }

}

View on GitHub (pinned to d6d39ce1c6)