{"record":{"id":"5036f2abc205dc93","repo":"apache/dolphinscheduler","slug":"taskgroupid-cannot-be-null","errorCode":null,"errorMessage":"taskGroupId cannot be null","messagePattern":"taskGroupId cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/TaskGroupDaoImpl.java","lineNumber":58,"sourceCode":"    @Override\n    public List<TaskGroup> queryAllTaskGroups() {\n        return mybatisMapper.selectList(null);\n    }\n\n    @Override\n    public List<TaskGroup> queryUsedTaskGroups() {\n        return mybatisMapper.queryUsedTaskGroups();\n    }\n\n    @Override\n    public List<TaskGroup> queryAvailableTaskGroups() {\n        return mybatisMapper.queryAvailableTaskGroups();\n    }\n\n    @Override\n    public boolean acquireTaskGroupSlot(Integer taskGroupId) {\n        if (taskGroupId == null) {\n            throw new IllegalArgumentException(\"taskGroupId cannot be null\");\n        }\n        return mybatisMapper.acquireTaskGroupSlot(taskGroupId) > 0;\n    }\n\n    @Override\n    public boolean releaseTaskGroupSlot(Integer taskGroupId) {\n        if (taskGroupId == null) {\n            throw new IllegalArgumentException(\"taskGroupId cannot be null\");\n        }\n        return mybatisMapper.releaseTaskGroupSlot(taskGroupId) > 0;\n    }\n}\n","sourceCodeStart":40,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/TaskGroupDaoImpl.java#L40-L71","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify the task actually belongs to a task group; skip slot acquisition when taskGroupId is null.","Check that the workflow/task configuration sets a valid task group id before execution.","Add a null guard at the caller so ungrouped tasks bypass the group-slot path."],"exampleFix":"// before\ntaskGroupDao.acquireTaskGroupSlot(taskInstance.getTaskGroupId()); // may be null\n// after\nif (taskInstance.getTaskGroupId() != null) {\n    taskGroupDao.acquireTaskGroupSlot(taskInstance.getTaskGroupId());\n}","handlingStrategy":"validation","validationCode":"if (taskInstance.getTaskGroupId() == null) {\n    return; // task is not in any task group, no slot needed\ntaskGroupDao.acquireTaskGroupSlot(taskInstance.getTaskGroupId());","typeGuard":"boolean hasTaskGroup(TaskInstance t) { return t != null && t.getTaskGroupId() != null; }","tryCatchPattern":"try {\n    taskGroupDao.acquireTaskGroupSlot(groupId);\n} catch (IllegalArgumentException e) {\n    log.error(\"taskGroupId is null; task not assigned to a group\", e);\n}","preventionTips":["Check taskGroupId on the TaskInstance before touching task-group APIs.","Ensure workflow/task configuration assigns a task group when group limits are expected.","Treat ungrouped tasks as a normal case, not an error."],"tags":["null-check","dao","task-group"],"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"}