{"record":{"id":"0eab83018e5ba728","repo":"amir20/dozzle","slug":"failed-to-parse-template-field-q-w","errorCode":null,"errorMessage":"failed to parse template field %q: %w","messagePattern":"failed to parse template field %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notification/dispatcher/webhook.go","lineNumber":329,"sourceCode":"\t\t}\n\t\treturn result, nil\n\tcase []any:\n\t\tresult := make([]any, len(val))\n\t\tfor i, child := range val {\n\t\t\tresolved, err := resolveTemplateValues(child, data)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tresult[i] = resolved\n\t\t}\n\t\treturn result, nil\n\tcase string:\n\t\tif !strings.Contains(val, \"{{\") {\n\t\t\treturn val, nil\n\t\t}\n\t\ttmpl, err := template.New(\"field\").Parse(val)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse template field %q: %w\", val, err)\n\t\t}\n\t\tvar buf bytes.Buffer\n\t\tif err := tmpl.Execute(&buf, data); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to execute template field %q: %w\", val, err)\n\t\t}\n\t\treturn buf.String(), nil\n\tdefault:\n\t\treturn val, nil\n\t}\n}\n","sourceCodeStart":311,"sourceCodeEnd":340,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/notification/dispatcher/webhook.go#L311-L340","documentation":"resolveTemplateValues walks the JSON template structure and, for any string value containing '{{', parses it as a Go text/template. This error is returned from template.Parse when the field's template syntax is invalid (unbalanced braces, bad action syntax, unknown functions at parse time). The field is never executed because parsing failed first.","triggerScenarios":"Any string field inside the webhook JSON structure that contains '{{' but has malformed template syntax: '{{ .Field' (missing closing braces), '{{range}}' without '{{end}}', or invalid action syntax. Raised inside resolveTemplateValues, which is called recursively by executeJSONTemplate.","commonSituations":"Users paste JSON with placeholders and accidentally delete a closing brace, mix template delimiters with shell ${} syntax, or write Go template actions with the wrong keyword.","solutions":["Read the wrapped parse error (%w cause); it names the exact field value and the syntax problem with a line/column.","Fix the template syntax in the offending field: balance all {{ }} pairs and close any range/if blocks with {{end}}.","If the braces are meant literally (not a placeholder), escape them or remove them so the field skips template parsing (fields without '{{' are returned as-is)."],"exampleFix":"// before (unclosed action)\n{\"text\": \"Container {{ .Name is down\"}\n// after\n{\"text\": \"Container {{ .Name }} is down\"}","handlingStrategy":"validation","validationCode":"if strings.Contains(val, \"{{\") {\n    if _, err := template.New(\"check\").Parse(val); err != nil {\n        return fmt.Errorf(\"invalid template field %q: %w\", val, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"resolved, err := resolveTemplateValues(structure, data)\nif err != nil {\n    return nil, fmt.Errorf(\"check webhook template syntax (balanced {{ }}): %w\", err)\n}","preventionTips":["Balance every {{ with a }} before saving templates.","Close every {{ range }}/{{ if }} with {{ end }}.","Validate templates in the UI at save time, not at dispatch time."],"tags":["webhook","template","parsing"],"backgroundTag":"template-parse-failed","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}