{"record":{"id":"9a731cfabd98bc95","repo":"vitessio/vitess","slug":"type-v-is-not-one-of-v","errorCode":null,"errorMessage":"type %v is not one of: %v","messagePattern":"type (.+?) is not one of: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/vtctl.go","lineNumber":908,"sourceCode":"\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\")\n\tshard := subFlags.String(\"shard\", \"\", \"The shard to which this tablet belongs\")\n\n\tvar tags flagutil.StringMapValue","sourceCodeStart":890,"sourceCodeEnd":926,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/vtctl.go#L890-L926","documentation":"parseTabletType also validates that the parsed tablet type is among the types allowed for the specific command (the `types` list parameter). This error fires when the type string is valid but not permitted for that operation — e.g. a type that the command refuses to set or list.","triggerScenarios":"Calling commandInitTablet or commandChangeTabletType with a legitimate tablet type that is outside the command's allowed list — e.g. attempting to change a tablet to MASTER via ChangeTabletType where MASTER is not in the permitted types, or listing with a disallowed filter type.","commonSituations":"Trying to demote/promote to MASTER with ChangeTabletType instead of the PlannedReparentShard workflow; filtering ListAllTablets by a type the command doesn't accept; scripts written for older Vitess versions where allowed sets differed.","solutions":["Use a type from the command's allowed list shown in the error message","For master promotion/demotion use `vtctl PlannedReparentShard` instead of ChangeTabletType","Check the command help to see which types are accepted","Adjust the script/config to pass a supported type"],"exampleFix":"// before\nvtctl ChangeTabletType zone1-0000000100 MASTER\n// after\nvtctl PlannedReparentShard commerce/0 zone1-0000000100\n","handlingStrategy":"validation","validationCode":"# Check the command's allowed types in help output before running\nvtctl ChangeTabletType --help | grep -A2 'tablet type'\n# and gate master changes to reparent workflows in your tooling\n[[ \"$TARGET_TYPE\" == \"MASTER\" ]] && { use_reparent_workflow; exit; }","typeGuard":null,"tryCatchPattern":"if err := runVtctl(\"ChangeTabletType\", alias, tt); err != nil {\n    if strings.Contains(err.Error(), \"is not one of:\") {\n        // parse allowed list from the message and retry with a permitted type\n    }\n}","preventionTips":["Never promote/demote masters with ChangeTabletType — use PlannedReparentShard","Consult per-command help for allowed type sets","Encode allowed transitions in your automation config","Review release notes when upgrading Vitess, as allowed sets may change"],"tags":["vtctl","tablet-type","validation"],"backgroundTag":"tablet-type-not-allowed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}