{"record":{"id":"8feba8e272b4f218","repo":"vitessio/vitess","slug":"failed-to-parse-vtgate-fqdn-template-s-w","errorCode":null,"errorMessage":"failed to parse vtgate FQDN template %s: %w","messagePattern":"failed to parse vtgate FQDN template (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/cluster/discovery/discovery_consul.go","lineNumber":135,"sourceCode":"\t\t\"Optional Go template string to produce an FQDN to access the vtctld from a browser. \"+\n\t\t\t\"E.g. \\\"{{ .Hostname }}.example.com\\\".\")\n\n\tif err := flags.Parse(args); err != nil {\n\t\treturn nil, err\n\t}\n\n\t/* gates options */\n\tif *vtgateDatacenterTmplStr != \"\" {\n\t\tdisco.vtgateDatacenter, err = generateConsulDatacenter(\"vtgate\", cluster, *vtgateDatacenterTmplStr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to generate vtgate consul datacenter from template: %w\", err)\n\t\t}\n\t}\n\n\tif *vtgateFQDNTmplStr != \"\" {\n\t\tdisco.vtgateFQDNTmpl, err = template.New(\"consul-vtgate-fqdn-template-\" + cluster.Id).Parse(*vtgateFQDNTmplStr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse vtgate FQDN template %s: %w\", *vtgateFQDNTmplStr, err)\n\t\t}\n\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)","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/cluster/discovery/discovery_consul.go#L117-L153","documentation":"During NewConsul, the vtgate FQDN template string is compiled with template.New(...).Parse. If parsing fails, the raw template string and underlying parse error are wrapped in this message. It indicates the vtgate fully-qualified-domain-name template is syntactically invalid Go template syntax.","triggerScenarios":"Calling NewConsul (via discovery.New(\"consul\", ...)) with a non-empty vtgate FQDN template flag containing invalid Go template syntax, e.g. \"{{ .Cluster.Id\" or an unknown pipeline function.","commonSituations":"Hand-edited YAML/env config with braces stripped or mangled by shell interpolation, copy-paste errors from docs, using fields not present on the Cluster proto.","solutions":["Fix the template syntax — ensure all {{ }} actions are closed and functions exist.","Verify referenced fields exist on vtadminpb.Cluster (e.g. {{ .Cluster.Id }}).","Empty the vtgate FQDN template flag to skip this option entirely.","Check the wrapped parse error message, which includes the template parse position."],"exampleFix":"// before\nvtgate_fqdn_template: \"{{ .Cluster.Id }-vtgate.example.com\"\n// after\nvtgate_fqdn_template: \"{{ .Cluster.Id }}-vtgate.example.com\"","handlingStrategy":"validation","validationCode":"if s := *vtgateFQDNTmplStr; s != \"\" {\n    if _, err := template.New(\"check\").Parse(s); err != nil {\n        return fmt.Errorf(\"invalid vtgate FQDN template %q: %w\", s, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"disco, err := NewConsul(cluster, args)\nif err != nil && strings.Contains(err.Error(), \"vtgate FQDN template\") {\n    log.Fatalf(\"fix vtgate FQDN template syntax: %v\", err)\n}","preventionTips":["Start from known-good examples like \"{{ .Cluster.Id }}-vtgate.example.com\".","Validate templates in CI by parsing every non-empty template flag.","Avoid shell interpolation that strips braces from env-provided templates."],"tags":["go","template","consul","fqdn","config"],"backgroundTag":"template-parse-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}