{"record":{"id":"aa9ef9836d119aa6","repo":"amir20/dozzle","slug":"failed-to-execute-template-field-q-w","errorCode":null,"errorMessage":"failed to execute template field %q: %w","messagePattern":"failed to execute template field %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notification/dispatcher/webhook.go","lineNumber":333,"sourceCode":"\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":315,"sourceCodeEnd":340,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/notification/dispatcher/webhook.go#L315-L340","documentation":"After a string field's template parses successfully, resolveTemplateValues executes it against the notification data. This error is returned when tmpl.Execute fails at render time, typically because the template references a key absent from the data map or applies an invalid operation to a data value. The whole template resolution aborts so no partially-rendered webhook payload is sent.","triggerScenarios":"A per-field template like '{{ .Missing }}' or '{{ .Level.SomeDeep.Field }}' executed against data that lacks that key or shape; also triggered by invalid pipeline usage (e.g. calling a non-function). Raised inside resolveTemplateValues via executeJSONTemplate.","commonSituations":"Users write placeholders against an imagined data schema (wrong key casing, deep JSON paths that don't exist), or reuse templates copied from another tool whose field names differ.","solutions":["Inspect the wrapped execute error; for missing keys it names the field that could not be evaluated.","Align the placeholder paths with the actual notification data structure (correct key names and nesting).","Use conditional/default rendering like '{{ if .Field }}{{ .Field }}{{ end }}' or sprig-style defaults if the field may be absent.","Test the template with a sample payload via SendTest before relying on it."],"exampleFix":"// before (deep path that may not exist)\n{\"text\": \"{{ .Container.Labels.dev.dozzle.name }}\"}\n// after (guard against absence)\n{\"text\": \"{{ if .Container }}{{ .Container.Name }}{{ end }}\"}","handlingStrategy":"try-catch","validationCode":"// Execute against a sample payload before persisting the template\nif _, err := resolveTemplateValues(sampleStructure, sampleData); err != nil {\n    return fmt.Errorf(\"template incompatible with data schema: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := tmpl.Execute(&buf, data); err != nil {\n    log.Printf(\"field %q failed to render, check data keys: %v\", val, err)\n    return fallbackValue\n}","preventionTips":["Copy field names from the documented notification payload, don't guess.","Guard optional fields with {{ if .Field }}.","Test with a representative payload covering all notification types."],"tags":["webhook","template","notifications"],"backgroundTag":"template-execution-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"}