{"record":{"id":"7c7a0ffd7ce567ce","repo":"vitessio/vitess","slug":"invalid-tablet-type-passed-s","errorCode":null,"errorMessage":"invalid tablet type passed %s","messagePattern":"invalid tablet type passed (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/utils.go","lineNumber":660,"sourceCode":"func encodeString(in string) string {\n\treturn sqltypes.EncodeStringSQL(in)\n}\n\nfunc getRenameFileName(tableName string) string {\n\treturn fmt.Sprintf(renameTableTemplate, tableName)\n}\n\nfunc parseTabletTypes(tabletTypes []topodatapb.TabletType) (hasReplica, hasRdonly, hasPrimary bool, err error) {\n\tfor _, tabletType := range tabletTypes {\n\t\tswitch tabletType {\n\t\tcase topodatapb.TabletType_REPLICA:\n\t\t\thasReplica = true\n\t\tcase topodatapb.TabletType_RDONLY:\n\t\t\thasRdonly = true\n\t\tcase topodatapb.TabletType_PRIMARY:\n\t\t\thasPrimary = true\n\t\tdefault:\n\t\t\treturn false, false, false, fmt.Errorf(\"invalid tablet type passed %s\", tabletType)\n\t\t}\n\t}\n\treturn hasReplica, hasRdonly, hasPrimary, nil\n}\n\nfunc areTabletsAvailableToStreamFrom(ctx context.Context, req *vtctldatapb.WorkflowSwitchTrafficRequest, ts *trafficSwitcher, keyspace string, shards []*topo.ShardInfo) error {\n\t// We use the value from the workflow for the TabletPicker.\n\ttabletTypesStr := ts.optTabletTypes\n\tcells := req.GetCells()\n\t// If no cells were provided in the command then use the value from the workflow.\n\tif len(cells) == 0 && ts.optCells != \"\" {\n\t\tcells = strings.Split(strings.TrimSpace(ts.optCells), \",\")\n\t}\n\n\tvar wg sync.WaitGroup\n\tallErrors := &concurrency.AllErrorRecorder{}\n\tfor _, shard := range shards {\n\t\twg.Add(1)","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/utils.go#L642-L678","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nreq.TabletTypes = []topodatapb.TabletType{topodatapb.TabletType(0)} // UNKNOWN\n// after\nreq.TabletTypes = []topodatapb.TabletType{topodatapb.TabletType_REPLICA, topodatapb.TabletType_RDONLY}","handlingStrategy":"validation","validationCode":"func validTabletTypes(tts []topodatapb.TabletType) bool {\n\tfor _, tt := range tts {\n\t\tswitch tt {\n\t\tcase topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA, topodatapb.TabletType_RDONLY:\n\t\t\tcontinue\n\t\tdefault:\n\t\t\treturn false\n\t\t}\n\t}\n\treturn len(tts) > 0\n}","typeGuard":"func isSwitchableTabletType(tt topodatapb.TabletType) bool {\n\treturn tt == topodatapb.TabletType_PRIMARY || tt == topodatapb.TabletType_REPLICA || tt == topodatapb.TabletType_RDONLY\n}","tryCatchPattern":"if err := ...; err != nil {\n\tif strings.Contains(err.Error(), \"invalid tablet type passed\") {\n\t\tlog.Warnf(\"bad tablet type in request: %v\", err)\n\t\treturn err // fix input, don't retry\n\t}\n}","preventionTips":["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"],"tags":["validation","tablet-types","vreplication","workflow"],"backgroundTag":"invalid-enum-value","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}