apache/dolphinscheduler · error · IllegalArgumentException

taskGroupId cannot be null

Error message

taskGroupId cannot be null

What it means

TaskGroupDaoImpl.acquireTaskGroupSlot performs an atomic UPDATE in the database to claim a slot in a task group. The task group id is required to target the row, so a null id is rejected with IllegalArgumentException before hitting the mapper.

Source

Thrown at dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/TaskGroupDaoImpl.java:58

    @Override
    public List<TaskGroup> queryAllTaskGroups() {
        return mybatisMapper.selectList(null);
    }

    @Override
    public List<TaskGroup> queryUsedTaskGroups() {
        return mybatisMapper.queryUsedTaskGroups();
    }

    @Override
    public List<TaskGroup> queryAvailableTaskGroups() {
        return mybatisMapper.queryAvailableTaskGroups();
    }

    @Override
    public boolean acquireTaskGroupSlot(Integer taskGroupId) {
        if (taskGroupId == null) {
            throw new IllegalArgumentException("taskGroupId cannot be null");
        }
        return mybatisMapper.acquireTaskGroupSlot(taskGroupId) > 0;
    }

    @Override
    public boolean releaseTaskGroupSlot(Integer taskGroupId) {
        if (taskGroupId == null) {
            throw new IllegalArgumentException("taskGroupId cannot be null");
        }
        return mybatisMapper.releaseTaskGroupSlot(taskGroupId) > 0;
    }
}

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Verify the task actually belongs to a task group; skip slot acquisition when taskGroupId is null.
  2. Check that the workflow/task configuration sets a valid task group id before execution.
  3. Add a null guard at the caller so ungrouped tasks bypass the group-slot path.

Example fix

// before
taskGroupDao.acquireTaskGroupSlot(taskInstance.getTaskGroupId()); // may be null
// after
if (taskInstance.getTaskGroupId() != null) {
    taskGroupDao.acquireTaskGroupSlot(taskInstance.getTaskGroupId());
}
Defensive patterns

Strategy: validation

Validate before calling

if (taskInstance.getTaskGroupId() == null) {
    return; // task is not in any task group, no slot needed
taskGroupDao.acquireTaskGroupSlot(taskInstance.getTaskGroupId());

Type guard

boolean hasTaskGroup(TaskInstance t) { return t != null && t.getTaskGroupId() != null; }

Try / catch

try {
    taskGroupDao.acquireTaskGroupSlot(groupId);
} catch (IllegalArgumentException e) {
    log.error("taskGroupId is null; task not assigned to a group", e);
}

Prevention

When it happens

Trigger: Calling acquireTaskGroupSlot(null), usually when the TaskGroup lookup that should supply the id failed or a task's taskGroupId field was never set (task not assigned to any group).

Common situations: Master dispatch logic acquiring slots for tasks that have no task group configured (taskGroupId is null on the TaskInstance); a getTaskGroupById returning null whose id is then forwarded.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/5036f2abc205dc93. Report an issue: GitHub.