fix: ensure reason present for workspace autoupdated notification (#17935)

Fixes https://github.com/coder/coder/issues/17930

Update the `WorkspaceAutoUpdated` notification to only display the
reason if it is present.
This commit is contained in:
Danielle Maywood
2025-05-20 16:01:57 +01:00
committed by GitHub
parent 769c9ee337
commit 1267c9c405

View File

@ -349,13 +349,18 @@ func (e *Executor) runOnce(t time.Time) Stats {
nextBuildReason = string(nextBuild.Reason)
}
templateVersionMessage := activeTemplateVersion.Message
if templateVersionMessage == "" {
templateVersionMessage = "None provided"
}
if _, err := e.notificationsEnqueuer.Enqueue(e.ctx, ws.OwnerID, notifications.TemplateWorkspaceAutoUpdated,
map[string]string{
"name": ws.Name,
"initiator": "autobuild",
"reason": nextBuildReason,
"template_version_name": activeTemplateVersion.Name,
"template_version_message": activeTemplateVersion.Message,
"template_version_message": templateVersionMessage,
}, "autobuild",
// Associate this notification with all the related entities.
ws.ID, ws.OwnerID, ws.TemplateID, ws.OrganizationID,