{"record":{"id":"e469c4b916aaea8a","repo":"apache/dolphinscheduler","slug":"110012","errorCode":"110012","errorMessage":"failed to delete the alert instance, there is an alarm group associated with this alert instance","messagePattern":"failed to delete the alert instance, there is an alarm group associated with this alert instance","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java","lineNumber":169,"sourceCode":"\n    /**\n     * delete alert plugin instance\n     *\n     * @param loginUser             login user\n     * @param alertPluginInstanceId id\n     * @return result\n     */\n    @Override\n    @Transactional\n    public void deleteById(User loginUser, int alertPluginInstanceId) {\n        if (!canOperatorPermissions(loginUser, null, AuthorizationType.ALERT_PLUGIN_INSTANCE, ALERT_PLUGIN_DELETE)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\n        // check if there is an associated alert group\n        boolean hasAssociatedAlertGroup = checkHasAssociatedAlertGroup(String.valueOf(alertPluginInstanceId));\n        if (hasAssociatedAlertGroup) {\n            throw new ServiceException(Status.DELETE_ALERT_PLUGIN_INSTANCE_ERROR_HAS_ALERT_GROUP_ASSOCIATED);\n        }\n\n        alertPluginInstanceMapper.deleteById(alertPluginInstanceId);\n    }\n\n    /**\n     * get alert plugin instance\n     *\n     * @param loginUser login user\n     * @param id get id\n     * @return alert plugin\n     */\n    @Override\n    public AlertPluginInstance getById(User loginUser, int id) {\n        if (!canOperatorPermissions(loginUser, null, AuthorizationType.ALERT_PLUGIN_INSTANCE, ALARM_INSTANCE_MANAGE)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n        return alertPluginInstanceMapper.selectById(id);","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java#L151-L187","documentation":"Thrown by deleteById when checkHasAssociatedAlertGroup() finds at least one alert group referencing this alert plugin instance. DolphinScheduler refuses to delete alert instances still in use by an alert group.","triggerScenarios":"Deleting an alert plugin instance whose id appears in the alertGroupId association of any alert group in t_ds_alert_group.","commonSituations":"Trying to remove an alert instance that is the notification target of a configured alert group; cleanup scripts unaware of group references.","solutions":["Remove the alert instance from all alert groups that reference it (edit or delete those groups in Security Center -> Alert group management).","Re-attempt the deletion once no alert group is associated.","Query t_ds_alert_group to find which groups reference the instance id."],"exampleFix":"// before\ndeleteAlertPluginInstance(instanceId);\n// after\nList<AlertGroup> groups = alertGroupMapper.listByAlertInstanceId(instanceId);\nif (!groups.isEmpty()) { /* detach or delete groups first */ }\ndeleteAlertPluginInstance(instanceId);","handlingStrategy":"validation","validationCode":"// check associations before delete\nList<AlertGroup> groups = alertGroupService.listByAlertInstanceId(instanceId);\nif (!groups.isEmpty()) throw new IllegalStateException(\"instance used by groups: \" + groups.stream().map(AlertGroup::getGroupName).collect(Collectors.toList()));","typeGuard":null,"tryCatchPattern":"try { alertPluginInstanceService.deleteById(loginUser, instanceId); } catch (ServiceException e) { if (e.getCode() == Status.DELETE_ALERT_PLUGIN_INSTANCE_ERROR_HAS_ALERT_GROUP_ASSOCIATED.getCode()) { /* show which groups reference the instance */ } throw e; }","preventionTips":["Show referencing alert groups in the UI delete confirmation","Detach instances from groups as part of decommission runbooks","Enforce referential checks in cleanup scripts"],"tags":["referential-integrity","deletion"],"backgroundTag":"invalid-state-transition","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"}