Grafana: Re-assigning a variable is throwing an Invalid Format Error

I am defining a notification template and i want to conditionally reassign the summary based on the labels. This is what I have:

      {{ define "alerts.summarize" }}
      {{ range . -}}
      {{ $summary_msg := index .Annotations "summary" }}
      {{ if eq .Labels.type "pipeline" }}
      {{ $summary_msg = printf "The %s is %s" .Labels.alertname (template "convert" .Values.A) }}
      {{- end }}
      {{ if eq .Status "firing" }}🚨{{ else }}βœ…{{- end }} {{ $summary_msg }} {{ if eq .Status "firing" }}🚨{{ else }}βœ…{{- end }}
      {{- end }}
      {{- end }}

However, the following line:

{{ $summary_msg = printf "The %s is %s" .Labels.alertname (template "convert" .Values.A) }}

is causing the following failure:
Error: βœ— text templates: [alerting.notifications.templates.invalidFormat] Invalid format of the submitted template

Why? This is valid go syntax!

Note that the issue is not in the message being printed into summary_msg because it’s valid when printing it straight to the console. There seems to be an issue when redirecting the printf output to the summary_msg