From ac3123a2ac2e29c406d7f0c5dcddd9640ecabf62 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 8 Apr 2025 16:27:19 +0100 Subject: [PATCH] Error reporting and handling in GH14575/GH12682 (#14802) Bug Error reporting and handling in GH14575/GH12682 This targets a bug that tries to parse blank string as None for panelid and dashboardid. It also prints more errors reporting to the console to diagnose reporting issues Co-authored-by: Lila Yasin --- awx/main/notifications/grafana_backend.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/awx/main/notifications/grafana_backend.py b/awx/main/notifications/grafana_backend.py index 153b004a5e..b9a2cbbc1e 100644 --- a/awx/main/notifications/grafana_backend.py +++ b/awx/main/notifications/grafana_backend.py @@ -53,8 +53,8 @@ class GrafanaBackend(AWXBaseEmailBackend, CustomNotificationBase): ): super(GrafanaBackend, self).__init__(fail_silently=fail_silently) self.grafana_key = grafana_key - self.dashboardId = int(dashboardId) if dashboardId is not None else None - self.panelId = int(panelId) if panelId is not None else None + self.dashboardId = int(dashboardId) if dashboardId is not None and panelId != "" else None + self.panelId = int(panelId) if panelId is not None and panelId != "" else None self.annotation_tags = annotation_tags if annotation_tags is not None else [] self.grafana_no_verify_ssl = grafana_no_verify_ssl self.isRegion = isRegion @@ -97,6 +97,7 @@ class GrafanaBackend(AWXBaseEmailBackend, CustomNotificationBase): r = requests.post( "{}/api/annotations".format(m.recipients()[0]), json=grafana_data, headers=grafana_headers, verify=(not self.grafana_no_verify_ssl) ) + if r.status_code >= 400: logger.error(smart_str(_("Error sending notification grafana: {}").format(r.status_code))) if not self.fail_silently: