{"record":{"id":"86b4a642fb3a0cfa","repo":"vitessio/vitess","slug":"failed-parsing-primary-term-start-time-s-w","errorCode":null,"errorMessage":"failed parsing primary_term_start_time %s: %w","messagePattern":"failed parsing primary_term_start_time (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/cluster/cluster.go","lineNumber":340,"sourceCode":"\t\treturn nil, err\n\t}\n\n\ttablet.State = vtadminproto.ParseTabletServingState(servingStateStr)\n\n\ttopotablet.Alias, err = topoproto.ParseTabletAlias(aliasStr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse tablet_alias %s: %w\", aliasStr, err)\n\t}\n\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\")","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/cluster/cluster.go#L322-L358","documentation":"Thrown by parseTablet when the tablet record carries a primary_term_start_time string that fails to parse as RFC3339 (time.Parse(time.RFC3339, ...)). Primary term start time marks when the current PRIMARY tablet's term began, and vtadmin expects it serialized in RFC3339 (e.g. 2023-01-02T15:04:05Z).","triggerScenarios":"Discovering tablets via parseTablets where the source record's primary_term_start_time field is non-empty but not RFC3339-formatted — e.g. a unix timestamp integer, a partial datetime, or locale-formatted time.","commonSituations":"Custom tooling or scripts writing tablet records with unix-epoch timestamps instead of RFC3339 strings; vttablet/vtctld version mismatch producing a different time serialization; hand-crafted test topo data.","solutions":["Check the primary_term_start_time value in the error message; convert the source to RFC3339 (e.g. `time.Unix(ts,0).UTC().Format(time.RFC3339)`).","If the value came from custom scripts/tooling, fix them to emit RFC3339 timestamps.","Upgrade/downgrade vtctld and vttablets so all components serialize times consistently (vitess protoutil conventions).","If the field should be unset, clear it so the empty-string guard (mtstStr != \"\") skips parsing."],"exampleFix":"// before\nmtstStr = \"1672674245\" // unix seconds, not RFC3339\n// after\nmtstStr = \"2023-01-02T15:04:05Z\" // time.Unix(1672674245,0).UTC().Format(time.RFC3339)","handlingStrategy":"validation","validationCode":"mtstStr := \"2023-01-02T15:04:05Z\"\nif _, err := time.Parse(time.RFC3339, mtstStr); err != nil {\n\treturn fmt.Errorf(\"primary_term_start_time %q is not RFC3339\", mtstStr)\n}","typeGuard":"func isRFC3339(s string) bool {\n\t_, err := time.Parse(time.RFC3339, s)\n\treturn err == nil\n}","tryCatchPattern":null,"preventionTips":["Serialize all timestamps with protoutil.TimeToProto / time.RFC3339, never raw unix integers.","Write a unit check for any custom tooling that writes tablet records to the topo.","Leave the field empty rather than writing a placeholder non-parseable value."],"tags":["vtadmin","time-parsing","rfc3339","tablet"],"backgroundTag":"invalid-timestamp-format","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}