{"record":{"id":"ad489ca6556f4b6f","repo":"thanos-io/thanos","slug":"invalid-alert-source-template","errorCode":null,"errorMessage":"invalid alert source template","messagePattern":"invalid alert source template","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/rule.go","lineNumber":380,"sourceCode":"\t\t\t\t\tHTTPConfig: clientconfig.HTTPConfig{\n\t\t\t\t\t\tEndpointsConfig: clientconfig.HTTPEndpointsConfig{\n\t\t\t\t\t\t\tScheme:        \"http\",\n\t\t\t\t\t\t\tFileSDConfigs: fileSDConfigs,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\n\t\tgrpcQueryCfg, err := clientconfig.BuildConfigFromGRPCAddresses(conf.grpcQueryEndpoints)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"query configuration\")\n\t\t}\n\t\tqueryCfg = append(queryCfg, grpcQueryCfg...)\n\t}\n\n\tif err := validateTemplate(*conf.alertmgr.alertSourceTemplate); err != nil {\n\t\treturn errors.Wrap(err, \"invalid alert source template\")\n\t}\n\n\tqueryProvider := dns.NewProvider(\n\t\tlogger,\n\t\textprom.WrapRegistererWithPrefix(\"thanos_rule_query_apis_\", reg),\n\t\tdns.ResolverType(conf.query.dnsSDResolver),\n\t)\n\tvar (\n\t\tqueryClients    []*clientconfig.HTTPClient\n\t\tpromClients     []*promclient.Client\n\t\tgrpcEndpointSet *query.EndpointSet\n\t\tgrpcEndpoints   []string\n\t)\n\n\tqueryClientMetrics := extpromhttp.NewClientMetrics(extprom.WrapRegistererWith(prometheus.Labels{\"client\": \"query\"}, reg))\n\n\tfor _, cfg := range queryCfg {\n\t\tif cfg.HTTPConfig.NotEmpty() {","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/rule.go#L362-L398","documentation":"This error is returned when validateTemplate rejects the alert source template configured for the Rule component's Alertmanager. runRule validates the template after building the query config. It means the alertsource template text is not a valid template (parse/compile failure).","triggerScenarios":"conf.alertmgr.alertSourceTemplate contains a template string that fails validateTemplate — e.g. unbalanced {{ }} braces or invalid template functions/actions.","commonSituations":"Hand-editing the --alert.source-template flag and leaving an unclosed `{{` or using a function the template engine doesn't expose; quoting problems in the shell stripping braces.","solutions":["Check the template braces are balanced and all actions are closed: {{ ... }}.","Simplify the template to a known-good minimal value and re-add parts until it fails to find the culprit.","Escape braces correctly for your shell/manifest (single-quote flag values in scripts).","Consult the validateTemplate implementation for the exact parse error wrapped under this message."],"exampleFix":"// before\n--alert.source-template='{{ if .Labels }}{{ .Labels\n// after\n--alert.source-template='{{ .GeneratorURL }}'","handlingStrategy":"validation","validationCode":"func validTemplate(t string) bool {\n    _, err := template.New(\"probe\").Funcs(funcMap).Parse(t)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Render the template with test data in CI (helm template / gotpl dry run).","Quote flag values in scripts to protect braces from the shell.","Start from a known-good minimal template and extend."],"tags":["thanos","template","config","startup"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}