{"record":{"id":"7833e248cb7edff3","repo":"apache/dolphinscheduler","slug":"not-allow-to-delete-default-alarm-group","errorCode":"NOT_ALLOW_TO_DELETE_DEFAULT_ALARM_GROUP","errorMessage":"NOT_ALLOW_TO_DELETE_DEFAULT_ALARM_GROUP","messagePattern":"NOT_ALLOW_TO_DELETE_DEFAULT_ALARM_GROUP","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java","lineNumber":239,"sourceCode":"    /**\n     * delete alert group by id\n     *\n     * @param loginUser login user\n     * @param id        alert group id\n     * @return delete result code\n     */\n    @Override\n    public void deleteAlertGroupById(User loginUser, int id) {\n\n        // only admin can operate\n        if (!canOperatorPermissions(loginUser, new Object[]{id}, AuthorizationType.ALERT_GROUP, ALERT_GROUP_DELETE)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\n        // Not allow to delete the default alarm group ,because the module of service need to use it.\n        if (id == 1) {\n            log.warn(\"Not allow to delete the default alarm group.\");\n            throw new ServiceException(Status.NOT_ALLOW_TO_DELETE_DEFAULT_ALARM_GROUP);\n        }\n\n        // check exist\n        AlertGroup alertGroup = alertGroupDao.queryById(id);\n        if (alertGroup == null) {\n            throw new ServiceException(Status.ALERT_GROUP_NOT_EXIST);\n        }\n\n        alertGroupDao.deleteById(id);\n        log.info(\"Delete alert group complete, groupId:{}\", id);\n    }\n\n    /**\n     * verify group name exists\n     *\n     * @param groupName group name\n     * @return check result code\n     */","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java#L221-L257","documentation":"Thrown by deleteAlertGroupById when attempting to delete the built-in default alert group (id == 1). DolphinScheduler reserves this group because internal services rely on it, so it is protected from deletion.","triggerScenarios":"Calling DELETE /alert-groups/1, i.e. any delete request targeting groupId 1 (the default alarm group).","commonSituations":"Cleanup scripts deleting all alert groups blindly; users confusing the default group with a disposable one; environment teardown automation iterating over all group IDs.","solutions":["Do not delete group id 1; delete only custom alert groups","Filter out id==1 in bulk-delete scripts","If the default group should not be used, create a new group and update alerts to reference it instead"],"exampleFix":"// before\nfor (AlertGroup g : groups) alertGroupService.deleteAlertGroupById(loginUser, g.getId());\n// after\nfor (AlertGroup g : groups) {\n    if (g.getId() != 1) alertGroupService.deleteAlertGroupById(loginUser, g.getId());\n}","handlingStrategy":"validation","validationCode":"if (id == 1) {\n    throw new IllegalArgumentException(\"the default alarm group (id=1) cannot be deleted\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never include group id 1 in deletion lists","Mark the default group as protected in automation tooling","Point workflows at a custom group instead of the default one"],"tags":["protected-resource","default-entity","api"],"backgroundTag":"unsupported-operation","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}