apache/dolphinscheduler · error · IllegalArgumentException

queryCondition can not be null

Error message

queryCondition can not be null

What it means

BaseDao.queryByCondition performs a conditional query by building a MyBatis-Plus QueryWrapper from the given entity. A null condition object cannot be converted to a query, and null also likely signals a caller bug (a query with no conditions should use queryAll instead), so the DAO throws IllegalArgumentException instead of returning the whole table.

Source

Thrown at dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/BaseDao.java:67

    }

    @Override
    public List<ENTITY> queryByIds(Collection<? extends Serializable> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return Collections.emptyList();
        }
        return mybatisMapper.selectBatchIds(ids);
    }

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

    @Override
    public List<ENTITY> queryByCondition(ENTITY queryCondition) {
        if (queryCondition == null) {
            throw new IllegalArgumentException("queryCondition can not be null");
        }
        return mybatisMapper.selectList(new QueryWrapper<>(queryCondition));
    }

    @Override
    public int insert(@NonNull ENTITY model) {
        return mybatisMapper.insert(model);
    }

    @Override
    public void insertBatch(Collection<ENTITY> models) {
        if (CollectionUtils.isEmpty(models)) {
            return;
        }
        for (ENTITY model : models) {
            insert(model);
        }
    }

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Ensure the condition entity is constructed and populated before calling queryByCondition.
  2. If you truly want all rows, call queryAll() (or pass a new empty instance of the entity) instead of null.
  3. Add a null check / Objects.requireNonNull at the call site to fail fast with a clearer message.

Example fix

// before
List<TaskInstance> list = taskInstanceDao.queryByCondition(taskInstanceDao.queryById(id).getTaskInstance()); // may be null
// after
TaskInstance cond = taskInstanceDao.queryById(id);
if (cond == null) {
    throw new IllegalStateException("condition entity not found");
}
List<TaskInstance> list = taskInstanceDao.queryByCondition(cond);
Defensive patterns

Strategy: validation

Validate before calling

if (condition == null) {
    throw new IllegalArgumentException("condition must be provided; use queryAll() for unfiltered queries");
}
daos.queryByCondition(condition);

Type guard

boolean isQueryable(ENTITY c) { return c != null; }

Try / catch

try {
    dao.queryByCondition(cond);
} catch (IllegalArgumentException e) {
    log.error("null condition passed to queryByCondition", e);
}

Prevention

When it happens

Trigger: Calling queryByCondition(null) on any repository that extends BaseDao, typically when the caller built the condition object in a variable that was never assigned or a lookup returned null before being passed in.

Common situations: Refactoring that renamed a condition object leaving it uninitialized; passing the result of an optional lookup directly into queryByCondition; generic helper code that does not check inputs before delegating to the DAO.

Related errors


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