{"record":{"id":"e12f56976dfe605e","repo":"vitessio/vitess","slug":"failed-to-execute-tablet-fqdn-template-for-v-w","errorCode":null,"errorMessage":"failed to execute tablet FQDN template for %+v: %w","messagePattern":"failed to execute tablet FQDN template for %\\+v: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/cluster/cluster.go","lineNumber":349,"sourceCode":"\n\tif topotablet.Alias.Cell != cell {\n\t\t// (TODO:@amason) ???\n\t\tlog.Warn(fmt.Sprintf(\"tablet cell %s does not match alias %s. ignoring for now\", cell, topoproto.TabletAliasString(topotablet.Alias)))\n\t}\n\n\tif mtstStr != \"\" {\n\t\ttimeTime, err := time.Parse(time.RFC3339, mtstStr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed parsing primary_term_start_time %s: %w\", mtstStr, err)\n\t\t}\n\n\t\ttopotablet.PrimaryTermStartTime = protoutil.TimeToProto(timeTime)\n\t}\n\n\tif c.TabletFQDNTmpl != nil {\n\t\ttablet.FQDN, err = textutil.ExecuteTemplate(c.TabletFQDNTmpl, tablet)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to execute tablet FQDN template for %+v: %w\", tablet, err)\n\t\t}\n\t}\n\n\treturn tablet, nil\n}\n\n// ApplySchema applies a schema to the given keyspace in this cluster.\nfunc (c *Cluster) ApplySchema(ctx context.Context, req *vtctldatapb.ApplySchemaRequest) (*vtctldatapb.ApplySchemaResponse, error) {\n\tspan, ctx := trace.NewSpan(ctx, \"Cluster.ApplySchema\")\n\tdefer span.Finish()\n\n\tAnnotateSpan(c, span)\n\tspan.Annotate(\"keyspace\", req.Keyspace)\n\tspan.Annotate(\"sql\", strings.Join(req.Sql, \"; \"))\n\tspan.Annotate(\"ddl_strategy\", req.DdlStrategy)\n\tspan.Annotate(\"uuid_list\", strings.Join(req.UuidList, \", \"))\n\tspan.Annotate(\"migration_context\", req.MigrationContext)\n","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/cluster/cluster.go#L331-L367","documentation":"Thrown by parseTablet when the cluster's TabletFQDNTmpl template fails to execute against the parsed tablet. vtadmin uses this Go text/template to derive each tablet's fully qualified domain name from its fields; template execution errors (bad syntax handled at parse time aside) surface here as wrapped errors.","triggerScenarios":"Calling tablet-discovery methods on a cluster configured with a TabletFQDNTmpl whose execution fails for a given tablet — e.g. the template references fields/keys not available on the tablet struct, or a custom function invoked by the template errors.","commonSituations":"Misconfigured vtadmin cluster.yaml `tabletFQDNTmpl` referencing wrong template variables (e.g. {{.Alias.Cell}} misspelled); template written for a different struct shape after a vtadmin version upgrade.","solutions":["Check the wrapped error and the printed tablet (%+v) to see which template expression failed.","Verify every field referenced in TabletFQDNTmpl exists on the vtadminpb.Tablet struct for your vtadmin version.","Test the template locally with text/template against a sample tablet struct before deploying.","Correct the template in the vtadmin cluster config (e.g. use {{.Tablet.Alias.Cell}}-{{.Tablet.Alias.Uid}} style references matching the actual struct)."],"exampleFix":"// before (template references nonexistent field)\ntabletFQDNTmpl: \"{{.Hostname}}.{{.BadField}}\"\n// after\ntabletFQDNTmpl: \"{{.Tablet.Alias.Cell}}-{{.Tablet.Alias.Uid}}.example.com\"","handlingStrategy":"validation","validationCode":"tmpl, err := template.New(\"fqdn\").Parse(cfg.TabletFQDNTmpl)\nif err != nil {\n\treturn fmt.Errorf(\"invalid tabletFQDNTmpl: %w\", err)\n}\nvar buf bytes.Buffer\nif err := tmpl.Execute(&buf, sampleTablet); err != nil {\n\treturn fmt.Errorf(\"tabletFQDNTmpl does not fit tablet struct: %w\", err)\n}","typeGuard":"func templateFits(tmplStr string, sample *vtadminpb.Tablet) bool {\n\tt, err := template.New(\"t\").Parse(tmplStr)\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn t.Execute(io.Discard, sample) == nil\n}","tryCatchPattern":null,"preventionTips":["Smoke-test TabletFQDNTmpl against a real tablet struct at vtadmin startup and fail fast on mismatch.","Reference only fields that exist on vtadminpb.Tablet for your vtadmin version; re-check after upgrades.","Keep the template in version-controlled config and lint it in CI."],"tags":["vtadmin","template","fqdn","configuration"],"backgroundTag":"template-execution-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}