Method transform not working together with url rewrite

The current go template for the response body transform is:

{{- if .error -}}
  "msg":"{{- .error.message -}}"
{{- else -}}
  {{- .response.result -}}
{{- end -}}

But you get the same problem also with a simpler one like:

{{ .error.message }}