prometheus / prometheus/alertmanager

Rendering notification templates should not silently swallow errors

Open
#5,322 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component/notify component/templating
Dominant language
Go
Stars
8.6k
Forks
2.5k
Avg merge
2d 6h
Merged PRs (30d)
61

Description

Proposal

Notifications templates are configured to silently swallow the errors and passing the final output, including the rendering error, to the underlying notification handler.

Depending on the notification handler, this may or may not work and errors may be reported in a very difficult way to investigate.

For instance, the Slack notifier accepts several configuration fields as Go templates. If one of the template fails to render, the error is ignored and the result sent to the Slack API, which may fail to process the message and fails with:

time=2026-06-23T15:14:49.930Z level=ERROR source=dispatch.go:611 msg="Notify for alerts failed" component=dispatcher aggrGroup="..." num_alerts=1 err="alerts/slack[0]: notify retry canceled due to unrecoverable error after 1 attempts: channel "": error response from Slack: invalid_arguments"

You then have to go through all the templates and find out which one was failing.

It would be much more resilient instead to:

  1. Log errors when templates are failing to render
  2. Not even try to call the notification handler if a related template fails to render

In my case, amtool template render correctly reports the problem so it could have been identified earlier, but as formatting can also be highly dependent on the alerts themselves, it may be difficult to achieve 100% test coverage ahead of time and not being able the actual error makes it really difficult to find out what the problem is.

Related:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing notification template rendering from the notification path and compare it with the behavior of amtool template render; the issue does not name specific source files or tests. Done means template rendering errors are logged and the notification handler is not called when a related template fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.