alerting: don't print a bare "value:" when ValueString is empty #96
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Jinemi/thermograph#96
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/alert-template-empty-value"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #94. A resolved notice landed in #ops-alerts reading
value:with nothing after it.Cause
The Discord contact point prints the value line unconditionally:
.ValueStringis only populated when the notification came from an evaluation that produced refIds. An instance resolved by Grafana's staleness handling has none — no evaluation ever returns that label set again, so the state manager expires it rather than evaluating it toNormal.That path is triggered by a rule
titlechange, because the title becomes thealertnamelabel and the old label set is orphaned. #94 renamedProdWorkerContainerSilent→ProdWorkerHeartbeatMissing, which orphaned the instance that had been firing since 2026-07-24T21:05Z; it expired at 18:05:47Z and posted its resolved notice with an empty ValueString.So the empty field is a real (if narrow) template bug, not a one-off cosmetic artifact of that rename — any future rule rename or label change hits it again.
Fix
Guard the whole line, not the substitution:
An unguarded
{{ .ValueString }}is harmless by itself — printing the label with nothing behind it is the bug. An empty labelled field reads as a value that failed to compute; an absent one correctly reads as "not applicable here".Verification
The file carries an explicit warning that a template error here breaks every notification silently, so this was not eyeballed. Both the
titleandmessagetemplates were extracted from the YAML and executed through Go'stext/templatewithValueStringset and empty:`value: [ var='A' ... ]`intactNothing else in the message changes.
The Discord template printed `value: {{ .ValueString }}` unconditionally, so a notification carrying no value rendered as "value:" with nothing after it — which reads as a value that failed to compute rather than one that was never applicable. ValueString is only populated when the notification came from an evaluation that produced refIds. An instance resolved by Grafana's staleness handling has none: no evaluation returns it again, so the state manager expires it. That is triggered by a rule title change, since the title becomes the alertname label and the old label set is orphaned — renaming ProdWorkerContainerSilent to ProdWorkerHeartbeatMissing did it and posted exactly that message. Guarding the whole line rather than the substitution: an unguarded {{ .ValueString }} is harmless on its own, printing the label is the bug. Verified by executing both templates through text/template with ValueString set and empty: parses and executes clean, populated output is byte-identical to the previous format, empty case omits the line.