{"record":{"id":"5d149679c4cfef9c","repo":"vitessio/vitess","slug":"failed-to-parse-vtctld-fqdn-template-s-w","errorCode":null,"errorMessage":"failed to parse vtctld FQDN template %s: %w","messagePattern":"failed to parse vtctld FQDN template (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/cluster/discovery/discovery_consul.go","lineNumber":155,"sourceCode":"\t}\n\n\tdisco.vtgateAddrTmpl, err = template.New(\"consul-vtgate-address-template-\" + cluster.Id).Parse(*vtgateAddrTmplStr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse vtgate host address template %s: %w\", *vtgateAddrTmplStr, err)\n\t}\n\n\t/* vtctld options */\n\tif *vtctldDatacenterTmplStr != \"\" {\n\t\tdisco.vtctldDatacenter, err = generateConsulDatacenter(\"vtctld\", cluster, *vtctldDatacenterTmplStr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to generate vtctld consul datacenter from template: %w\", err)\n\t\t}\n\t}\n\n\tif *vtctldFQDNTmplStr != \"\" {\n\t\tdisco.vtctldFQDNTmpl, err = template.New(\"consul-vtctld-fqdn-template-\" + cluster.Id).Parse(*vtctldFQDNTmplStr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse vtctld FQDN template %s: %w\", *vtctldFQDNTmplStr, err)\n\t\t}\n\t}\n\n\tdisco.vtctldAddrTmpl, err = template.New(\"consul-vtctld-address-template-\" + cluster.Id).Parse(*vtctldAddrTmplStr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse vtctld host address template %s: %w\", *vtctldAddrTmplStr, err)\n\t}\n\n\treturn disco, nil\n}\n\nfunc generateConsulDatacenter(component string, cluster *vtadminpb.Cluster, tmplStr string) (string, error) {\n\ttmpl, err := template.New(\"consul-\" + component + \"-datacenter-\" + cluster.Id).Parse(tmplStr)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error parsing template %s: %w\", tmplStr, err)\n\t}\n\n\tdc, err := textutil.ExecuteTemplate(tmpl, &struct {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/cluster/discovery/discovery_consul.go#L137-L173","documentation":"NewConsul compiles the vtctld FQDN template with template.Parse; failure is wrapped with the raw template string and the parse error. This means the vtctld fully-qualified-domain-name template is not valid Go template syntax.","triggerScenarios":"Calling NewConsul (through discovery.New(\"consul\", ...)) with a non-empty vtctld FQDN template flag containing syntax errors such as unbalanced braces, stray text/template operators, or calls to unregistered functions.","commonSituations":"Typo when duplicating the vtgate template for vtctld, quoting issues in YAML/env, referencing fields absent from vtadminpb.Cluster.","solutions":["Correct the template syntax so template.Parse succeeds.","Mirror a known-good template, e.g. \"{{ .Cluster.Id }}-vtctld.example.com\".","Empty the flag to skip the vtctld FQDN option entirely.","Use the wrapped parse error to locate the bad token/offset."],"exampleFix":"// before\nvtctld_fqdn_template: \"{{ .Cluster.Id }}-vtctld{{\"\n// after\nvtctld_fqdn_template: \"{{ .Cluster.Id }}-vtctld.example.com\"","handlingStrategy":"validation","validationCode":"if s := *vtctldFQDNTmplStr; s != \"\" {\n    if _, err := template.New(\"check\").Parse(s); err != nil {\n        return fmt.Errorf(\"invalid vtctld FQDN template %q: %w\", s, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"disco, err := NewConsul(cluster, args)\nif err != nil && strings.Contains(err.Error(), \"vtctld FQDN template\") {\n    log.Fatalf(\"fix vtctld FQDN template: %v\", err)\n}","preventionTips":["Use canonical examples: \"{{ .Cluster.Id }}-vtctld.example.com\".","Run template.Parse in a startup validation step for every template flag.","Avoid mixing vtgate and vtctld values in shared env vars."],"tags":["go","template","consul","vtctld","fqdn"],"backgroundTag":"template-parse-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}