From ff5cab992b4d121372bd9af8756ca7d67188f2dd Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 18 Oct 2026 23:44:22 +1100 Subject: [PATCH] fix(postgres): task alert body carries the truncated task title, not a restated title --- internal/infrastructure/postgres/task_alerts.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/infrastructure/postgres/task_alerts.go b/internal/infrastructure/postgres/task_alerts.go index 067ae2b88..d2f40cf8e 100644 --- a/internal/infrastructure/postgres/task_alerts.go +++ b/internal/infrastructure/postgres/task_alerts.go @@ -57,7 +57,7 @@ func syncTaskAlerts(ctx context.Context, q *postgresdb.Queries, p postgresdb.Ins name := fmt.Sprintf("Task #%d", p.TaskID) title := name if info.Title != "" { - title = info.Title + title = truncate(info.Title, 80) } key := func(kind string) alert.Key { return alert.Key{Org: org.OrgID(info.OrgID), Kind: kind, Subject: subject} @@ -83,9 +83,18 @@ func syncTaskAlerts(ctx context.Context, q *postgresdb.Queries, p postgresdb.Ins if failed(p.ToStatus, info.ParkClass) { _, err := raiseAlert(ctx, q, alert.Input{ Key: key(alert.KindTaskFailed), Severity: alert.SeverityWarning, - Title: title, Body: name + " failed and will not run again until you retry it.", Link: link, + Title: title, Body: name + " failed.", Link: link, }) return err } return nil } + +// truncate shortens s to at most n runes, marking the cut with an ellipsis. +func truncate(s string, n int) string { + r := []rune(s) + if len(r) <= n { + return s + } + return string(r[:n-1]) + "…" +}