{"record":{"id":"d7e70589448d0bc8","repo":"vitessio/vitess","slug":"invalid-tablet-type-v-v","errorCode":null,"errorMessage":"invalid tablet type %v: %v","messagePattern":"invalid tablet type (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/vtctl.go","lineNumber":905,"sourceCode":"// to tablet aliases.\nfunc tabletParamsToTabletAliases(params []string) ([]*topodatapb.TabletAlias, error) {\n\tresult := make([]*topodatapb.TabletAlias, len(params))\n\tvar err error\n\tfor i, param := range params {\n\t\tresult[i], err = topoproto.ParseTabletAlias(param)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn result, nil\n}\n\n// parseTabletType parses the string tablet type and verifies\n// it is an accepted one\nfunc parseTabletType(param string, types []topodatapb.TabletType) (topodatapb.TabletType, error) {\n\ttabletType, err := topoproto.ParseTabletType(param)\n\tif err != nil {\n\t\treturn topodatapb.TabletType_UNKNOWN, fmt.Errorf(\"invalid tablet type %v: %v\", param, err)\n\t}\n\tif !topoproto.IsTypeInList(topodatapb.TabletType(tabletType), types) {\n\t\treturn topodatapb.TabletType_UNKNOWN, fmt.Errorf(\"type %v is not one of: %v\", tabletType, strings.Join(topoproto.MakeStringTypeList(types), \" \"))\n\t}\n\treturn tabletType, nil\n}\n\nfunc commandInitTablet(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {\n\tdbNameOverride := subFlags.String(\"db_name_override\", \"\", \"Overrides the name of the database that the vttablet uses\")\n\tallowUpdate := subFlags.Bool(\"allow_update\", false, \"Use this flag to force initialization if a tablet with the same name already exists. Use with caution.\")\n\tallowPrimaryOverride := subFlags.Bool(\"allow_master_override\", false, \"Use this flag to force initialization if a tablet is created as primary, and a primary for the keyspace/shard already exists. Use with caution.\")\n\tcreateShardAndKeyspace := subFlags.Bool(\"parent\", false, \"Creates the parent shard and keyspace if they don't yet exist\")\n\thostname := subFlags.String(\"hostname\", \"\", \"The server on which the tablet is running\")\n\tmysqlHost := subFlags.String(\"mysql_host\", \"\", \"The mysql host for the mysql server\")\n\tmysqlPort := subFlags.Int(\"mysql-port\", 0, \"The mysql port for the mysql server\")\n\tport := subFlags.Int(\"port\", 0, \"The main port for the vttablet process\")\n\tgrpcPort := subFlags.Int(\"grpc-port\", 0, \"The gRPC port for the vttablet process\")\n\tkeyspace := subFlags.String(\"keyspace\", \"\", \"The keyspace to which this tablet belongs\")","sourceCodeStart":887,"sourceCodeEnd":923,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/vtctl.go#L887-L923","documentation":"parseTabletType converts a string CLI argument into a topodatapb.TabletType and validates it is a parseable type name. This error is returned when topoproto.ParseTabletType cannot recognize the string, meaning the user supplied a value that is not a valid Vitess tablet type.","triggerScenarios":"Passing a misspelled or unknown type string to commandInitTablet, commandChangeTabletType, or commandListAllTablets, e.g. `vtctl ChangeTabletType alias REPLCA` — ParseTabletType fails and this wraps that error.","commonSituations":"Typos in type names (REPLICA, RDONLY); using MySQL-ish terms like 'slave' in versions where only REPLICA is accepted; extra whitespace or wrong casing.","solutions":["Use one of the valid type strings: MASTER, REPLICA, RDONLY, SPARE, BACKUP, RESTORE, DRAINED, etc.","Check spelling and casing against `vtctl ChangeTabletType --help`","Remove stray whitespace/special characters from the argument","For older tooling, replace deprecated terms (e.g. 'slave') with current names (REPLICA)"],"exampleFix":"// before\nvtctl ChangeTabletType zone1-0000000100 REPLCA\n// after\nvtctl ChangeTabletType zone1-0000000100 REPLICA\n","handlingStrategy":"validation","validationCode":"VALID_TYPES=\"MASTER REPLICA RDONLY SPARE BACKUP RESTORE DRAINED EXPERIMENTAL\"\nvalidate_tablet_type() {\n  case \"$1\" in\n    $VALID_TYPES) return 0 ;;\n    *) echo \"invalid tablet type: $1\"; return 1 ;;\n  esac\n}\nvalidate_tablet_type \"$TYPE\" || exit 1","typeGuard":null,"tryCatchPattern":"if err := runVtctl(\"ChangeTabletType\", alias, tt); err != nil {\n    if strings.Contains(err.Error(), \"invalid tablet type\") {\n        // surface the accepted type list to the operator\n    }\n}","preventionTips":["Validate tablet type strings against the enum in scripts before invoking vtctl","Use constants, not inline strings, for tablet types in automation","Strip whitespace from CLI inputs","Keep scripts updated with current type names (REPLICA, not SLAVE)"],"tags":["vtctl","tablet-type","validation"],"backgroundTag":"invalid-tablet-type","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}