{"record":{"id":"19003611a25ca1d0","repo":"amir20/dozzle","slug":"failed-to-parse-template-w","errorCode":null,"errorMessage":"failed to parse template: %w","messagePattern":"failed to parse template: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notification/dispatcher/webhook.go","lineNumber":190,"sourceCode":"\t\tName:         name,\n\t\tURL:          rawURL,\n\t\tTemplateText: templateStr,\n\t\tHeaders:      headers,\n\t\tclient: &http.Client{\n\t\t\tTimeout: 10 * time.Second,\n\t\t\tTransport: &http.Transport{\n\t\t\t\tDialContext:           safeDialContext,\n\t\t\t\tTLSHandshakeTimeout:   10 * time.Second,\n\t\t\t\tResponseHeaderTimeout: 10 * time.Second,\n\t\t\t\tExpectContinueTimeout: 1 * time.Second,\n\t\t\t},\n\t\t},\n\t}\n\n\tif templateStr != \"\" {\n\t\ttmpl, err := template.New(\"webhook\").Parse(templateStr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse template: %w\", err)\n\t\t}\n\t\tw.Template = tmpl\n\t}\n\n\treturn w, nil\n}\n\n// TestResult contains the result of a webhook test\ntype TestResult struct {\n\tSuccess    bool\n\tStatusCode int\n\tError      string\n}\n\n// Send sends a notification to the webhook URL\nfunc (w *WebhookDispatcher) Send(ctx context.Context, notification types.Notification) error {\n\tresult := w.SendTest(ctx, notification)\n\tif !result.Success {","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/notification/dispatcher/webhook.go#L172-L208","documentation":"When a non-empty templateStr is supplied, NewWebhookDispatcher parses it with text/template at construction time. A syntactically invalid template (unclosed actions, bad pipeline syntax) aborts dispatcher creation with this wrapped error.","triggerScenarios":"Calling NewWebhookDispatcher with templateStr that text/template cannot parse, e.g. \"{{ .Message\" (missing closing braces) or \"{{ .Field | }\" (empty pipeline).","commonSituations":"Hand-written JSON templates with typos in {{ }} actions; templates copied from other engines (Jinja2 {{ }}, ${var} syntax) that Go templates reject; YAML config mangling braces.","solutions":["Check the wrapped parse error; it names the template and character position","Ensure every {{ }} action is closed and pipelines are valid Go template syntax","Test the template standalone with template.New(\"webhook\").Parse before saving the config","If you just want raw JSON of the notification, pass an empty templateStr instead"],"exampleFix":"// before\nNewWebhookDispatcher(\"hook\", url, \"{\\\"text\\\": \\\"{{ .Message \\\"}\", nil)\n// after\nNewWebhookDispatcher(\"hook\", url, \"{\\\"text\\\": \\\"{{ .Message }}\\\"}\", nil)","handlingStrategy":"validation","validationCode":"if _, err := template.New(\"webhook\").Parse(tpl); err != nil {\n    return fmt.Errorf(\"invalid webhook template: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"d, err := NewWebhookDispatcher(name, rawURL, tpl, headers)\nif err != nil && strings.Contains(err.Error(), \"failed to parse template\") {\n    // show template syntax error to user\n}","preventionTips":["Preview-render the template against a sample notification before saving","Use Go template syntax only; do not mix Jinja/${} placeholders","Pass empty templateStr when you want default JSON marshaling"],"tags":["template","validation","webhook","config"],"backgroundTag":"invalid-regex-pattern","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"}