You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The slack user and group mentions should check the length of the rendered go template when deciding whether or not to add a mention to the slack pretext. Currently, the logic checks the length of the source string for it's conditional logic, and renders the template when interpolating it into the slack pretext.
This is a problem, because if the go template renders into an empty string, a broken mention will be added to the pretext.
To reproduce, use {{- /* empty */ -}} as the "Mention Groups" configuration setting.
Hey @armandgrillet - For reasons, I checked the codebase a bit, and found this bug. If it is still valid, I have a fix here (I think, if I understood everything correctly): main...DGuhr:alerting:fix_slack_broken_mentions - see tests for details. Happy to provide a PR if you want.
Alternatively, I think, the check could be added to the config_util.go method for comma separated strings, but this is also used elsewhere and I wanted to avoid impacting other behaviour.
edit: on second glance, I saw that splitCommaSeparatedString in config_util does exactly what I did here, so I guess that the bug doesn't exist anymore or I am missing some context currently. sry for the noise so-far.
DGuhr
added a commit
to DGuhr/alerting
that referenced
this issue
Feb 17, 2024
The slack user and group mentions should check the length of the rendered go template when deciding whether or not to add a mention to the slack pretext. Currently, the logic checks the length of the source string for it's conditional logic, and renders the template when interpolating it into the slack pretext.
This is a problem, because if the go template renders into an empty string, a broken mention will be added to the pretext.
To reproduce, use
{{- /* empty */ -}}
as the "Mention Groups" configuration setting.alerting/receivers/slack/slack.go
Lines 368 to 380 in 939f557
The text was updated successfully, but these errors were encountered: