{"record":{"id":"4a12d112794b3cd5","repo":"apache/dolphinscheduler","slug":"querycondition-can-not-be-null","errorCode":null,"errorMessage":"queryCondition can not be null","messagePattern":"queryCondition can not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/BaseDao.java","lineNumber":67,"sourceCode":"    }\n\n    @Override\n    public List<ENTITY> queryByIds(Collection<? extends Serializable> ids) {\n        if (CollectionUtils.isEmpty(ids)) {\n            return Collections.emptyList();\n        }\n        return mybatisMapper.selectBatchIds(ids);\n    }\n\n    @Override\n    public List<ENTITY> queryAll() {\n        return mybatisMapper.selectList(null);\n    }\n\n    @Override\n    public List<ENTITY> queryByCondition(ENTITY queryCondition) {\n        if (queryCondition == null) {\n            throw new IllegalArgumentException(\"queryCondition can not be null\");\n        }\n        return mybatisMapper.selectList(new QueryWrapper<>(queryCondition));\n    }\n\n    @Override\n    public int insert(@NonNull ENTITY model) {\n        return mybatisMapper.insert(model);\n    }\n\n    @Override\n    public void insertBatch(Collection<ENTITY> models) {\n        if (CollectionUtils.isEmpty(models)) {\n            return;\n        }\n        for (ENTITY model : models) {\n            insert(model);\n        }\n    }","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/BaseDao.java#L49-L85","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the condition entity is constructed and populated before calling queryByCondition.","If you truly want all rows, call queryAll() (or pass a new empty instance of the entity) instead of null.","Add a null check / Objects.requireNonNull at the call site to fail fast with a clearer message."],"exampleFix":"// before\nList<TaskInstance> list = taskInstanceDao.queryByCondition(taskInstanceDao.queryById(id).getTaskInstance()); // may be null\n// after\nTaskInstance cond = taskInstanceDao.queryById(id);\nif (cond == null) {\n    throw new IllegalStateException(\"condition entity not found\");\n}\nList<TaskInstance> list = taskInstanceDao.queryByCondition(cond);","handlingStrategy":"validation","validationCode":"if (condition == null) {\n    throw new IllegalArgumentException(\"condition must be provided; use queryAll() for unfiltered queries\");\n}\ndaos.queryByCondition(condition);","typeGuard":"boolean isQueryable(ENTITY c) { return c != null; }","tryCatchPattern":"try {\n    dao.queryByCondition(cond);\n} catch (IllegalArgumentException e) {\n    log.error(\"null condition passed to queryByCondition\", e);\n}","preventionTips":["Never pass null to BaseDao conditional methods; use queryAll for unfiltered reads.","Null-check entities fetched from lookups before reusing them as query conditions.","Prefer explicit QueryWrapper-style queries for dynamic conditions."],"tags":["null-check","dao","illegal-argument"],"backgroundTag":"null-argument","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}