From 82c564fecbdd750bb507320a6eb4efca701fd6e6 Mon Sep 17 00:00:00 2001 From: Ildar Iskhakov Date: Mon, 23 Sep 2024 16:45:32 +0800 Subject: [PATCH] Check for invalid urls in slack (#5055) # What this PR does We recently changed the default template (https://github.com/grafana/oncall/pull/5005) but some alertmanagers may send invalid URLs. Our fronted has the check for invalid URLs ("he Integration template Source Link is invalid"), but slack does not, so I added this check ## Which issue(s) this PR closes Related to [issue link here] ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [ ] Documentation added (or `pr:no public docs` PR label added if not required) - [ ] Added the relevant release notes label (see labels prefixed w/ `release:`). These labels dictate how your PR will show up in the autogenerated release notes. --- engine/config_integrations/alertmanager.py | 2 +- engine/config_integrations/grafana_alerting.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/config_integrations/alertmanager.py b/engine/config_integrations/alertmanager.py index 2df1d9bc..5b8535b2 100644 --- a/engine/config_integrations/alertmanager.py +++ b/engine/config_integrations/alertmanager.py @@ -107,7 +107,7 @@ Annotations: # Slack slack_title = """\ *<{{ grafana_oncall_link }}|#{{ grafana_oncall_incident_id }} {{ web_title }}>* via {{ integration_name }} -{% if source_link %} +{% if source_link and (source_link[:8] == "https://" or source_link[:7] == "http://") %} (*<{{ source_link }}|source>*) {%- endif %} """ diff --git a/engine/config_integrations/grafana_alerting.py b/engine/config_integrations/grafana_alerting.py index 0dc5b6d6..a53ddccf 100644 --- a/engine/config_integrations/grafana_alerting.py +++ b/engine/config_integrations/grafana_alerting.py @@ -109,7 +109,7 @@ Annotations: # Slack slack_title = """\ *<{{ grafana_oncall_link }}|#{{ grafana_oncall_incident_id }} {{ web_title }}>* via {{ integration_name }} -{% if source_link %} +{% if source_link and (source_link[:8] == "https://" or source_link[:7] == "http://") %} (*<{{ source_link }}|source>*) {%- endif %} """