vitessio/vitess · error
invalid tablet type passed %s
Error message
invalid tablet type passed %s
What it means
parseTabletTypes validates each tablet type requested for a vreplication workflow traffic switch against the three supported values (PRIMARY, REPLICA, RDONLY). Any other topodatapb.TabletType enum value — typically an unset/UNRECOGNIZED or UNKNOWN value — is rejected immediately with this error. It is a pure input-validation failure: the workflow switch cannot proceed because the caller passed a tablet type the switcher cannot serve traffic for.
Source
Thrown at go/vt/vtctl/workflow/utils.go:660
func encodeString(in string) string {
return sqltypes.EncodeStringSQL(in)
}
func getRenameFileName(tableName string) string {
return fmt.Sprintf(renameTableTemplate, tableName)
}
func parseTabletTypes(tabletTypes []topodatapb.TabletType) (hasReplica, hasRdonly, hasPrimary bool, err error) {
for _, tabletType := range tabletTypes {
switch tabletType {
case topodatapb.TabletType_REPLICA:
hasReplica = true
case topodatapb.TabletType_RDONLY:
hasRdonly = true
case topodatapb.TabletType_PRIMARY:
hasPrimary = true
default:
return false, false, false, fmt.Errorf("invalid tablet type passed %s", tabletType)
}
}
return hasReplica, hasRdonly, hasPrimary, nil
}
func areTabletsAvailableToStreamFrom(ctx context.Context, req *vtctldatapb.WorkflowSwitchTrafficRequest, ts *trafficSwitcher, keyspace string, shards []*topo.ShardInfo) error {
// We use the value from the workflow for the TabletPicker.
tabletTypesStr := ts.optTabletTypes
cells := req.GetCells()
// If no cells were provided in the command then use the value from the workflow.
if len(cells) == 0 && ts.optCells != "" {
cells = strings.Split(strings.TrimSpace(ts.optCells), ",")
}
var wg sync.WaitGroup
allErrors := &concurrency.AllErrorRecorder{}
for _, shard := range shards {
wg.Add(1)View on GitHub (pinned to 01a25a7d17)
Solutions
- Print the exact tablet type from the error message and check it against the supported set: PRIMARY, REPLICA, RDONLY.
- Fix the vtctldclient flag (e.g. --tablet-types="replica,rdonly") or the proto request so tablet_types only contains valid values.
- If building the request in code, explicitly set each TabletType with topodatapb.TabletType_value["REPLICA"] etc. instead of relying on zero values.
- Upgrade the client if it predates the current topodatapb.TabletType enum.
Example fix
// before
req.TabletTypes = []topodatapb.TabletType{topodatapb.TabletType(0)} // UNKNOWN
// after
req.TabletTypes = []topodatapb.TabletType{topodatapb.TabletType_REPLICA, topodatapb.TabletType_RDONLY} Defensive patterns
Strategy: validation
Validate before calling
func validTabletTypes(tts []topodatapb.TabletType) bool {
for _, tt := range tts {
switch tt {
case topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA, topodatapb.TabletType_RDONLY:
continue
default:
return false
}
}
return len(tts) > 0
} Type guard
func isSwitchableTabletType(tt topodatapb.TabletType) bool {
return tt == topodatapb.TabletType_PRIMARY || tt == topodatapb.TabletType_REPLICA || tt == topodatapb.TabletType_RDONLY
} Try / catch
if err := ...; err != nil {
if strings.Contains(err.Error(), "invalid tablet type passed") {
log.Warnf("bad tablet type in request: %v", err)
return err // fix input, don't retry
}
} Prevention
- Only construct tablet type lists from the named enum constants, never from raw ints or strings
- Validate user-supplied --tablet-types strings against topodatapb.TabletType_value before building requests
- Add a unit test asserting validTabletTypes rejects zero-value enums
When it happens
Trigger: Calling WorkflowSwitchTraffic (vtctldclient MoveTables SwitchTraffic / LookupVindex or similar) with a TabletTypes option containing a value other than PRIMARY, REPLICA, or RDONLY — e.g. an empty string serialized to the enum zero value, a typo'd flag value, or a programmatically constructed request with TableType_BATCH or an unset field.
Common situations: Automated tooling builds a WorkflowSwitchTrafficRequest and leaves tablet_types unset (protobuf default 0 = UNKNOWN); a script passes a misspelled tablet type; an older client sends a legacy tablet-type value not in the supported set.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- vreplication streams are not frozen on tablet %d
- value out of range
- both atomic copy and partial mode cannot be specified for th
- invalid workflow
- multiple source keyspaces for a single workflow
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/7c7a0ffd7ce567ce.
Report an issue: GitHub.