From 058665b8a8e35f0264ccd72141a64541ba087594 Mon Sep 17 00:00:00 2001 From: Yulya Artyukhina Date: Mon, 20 Feb 2023 11:42:44 +0100 Subject: [PATCH] Fix too long declare incident link (#1342) # What this PR does ## Which issue(s) this PR fixes Issue with too long declare incident link in Slack ## Checklist - [x] `CHANGELOG.md` updated --- CHANGELOG.md | 6 ++++++ engine/apps/alerts/models/alert_group.py | 1 + 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d94831da..b48d07be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Fixed too long declare incident link in Slack + ## v1.1.24 (2023-02-16) ### Added diff --git a/engine/apps/alerts/models/alert_group.py b/engine/apps/alerts/models/alert_group.py index fe7cdfc5..d27f4332 100644 --- a/engine/apps/alerts/models/alert_group.py +++ b/engine/apps/alerts/models/alert_group.py @@ -480,6 +480,7 @@ class AlertGroup(AlertGroupSlackRenderingMixin, EscalationSnapshotMixin, models. incident_link = urljoin(self.channel.organization.grafana_url, "a/grafana-incident-app/incidents/declare/") caption = urllib.parse.quote_plus("OnCall Alert Group") title = urllib.parse.quote_plus(self.web_title_cache) if self.web_title_cache else DEFAULT_BACKUP_TITLE + title = title[:2000] # set max title length to avoid exceptions with too long declare incident link link = urllib.parse.quote_plus(self.web_link) return urljoin(incident_link, f"?caption={caption}&url={link}&title={title}")