Skip to content

Omit zero end times from Alertmanager notifications - #1946

Merged
binwiederhier merged 1 commit into
binwiederhier:mainfrom
justadityaraj:fix/1940-alertmanager-end-time
Oct 7, 2026
Merged

binwiederhier merged 1 commit into
binwiederhier:mainfrom
justadityaraj:fix/1940-alertmanager-end-time

Conversation

@justadityaraj

Copy link
Copy Markdown
Contributor

Context

The built-in Alertmanager template treats the zero endsAt value on firing alerts as a real end time. Its whitespace trim also joins a resolved alert's start and end timestamps onto one line.

Fixes #1940

Changes

  • Render Ends at: only when endsAt is present and nonzero.
  • Preserve the newline before a resolved alert's end time.
  • Cover firing and resolved rendering with the bundled Alertmanager fixture.

User impact

Firing notifications no longer show a year-one end timestamp, while resolved notifications show their end timestamp on a separate line.

Verification

  • The regression fails on 10cb6506 with Starts at: 2025-07-17T07:00:00ZEnds at: 0001-01-01T00:00:00Z and passes with this change.
  • Go 1.27.0: focused regression passed 10/10.
  • go vet ./server — passed.
  • go mod tidy — no module changes.
  • make template-check with Go 1.27.0 — passed.
  • gofmt -l server/server_test.go — no output.
  • go test ./... -count=1 — attempted; the Windows host has CGO_ENABLED=0, while ntfy's documented SQLite test setup requires gcc/cgo. SQLite-dependent tests therefore use the go-sqlite3 stub; unrelated Unix-socket and open-log cleanup tests also fail on this host.

@binwiederhier
binwiederhier merged commit ea5912b into binwiederhier:main Oct 7, 2026
@binwiederhier

Copy link
Copy Markdown
Owner

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alertmanager template renders firing end time incorrectly

2 participants