{"record":{"id":"f51ec6d8cf1b979f","repo":"vitessio/vitess","slug":"the-tablet-alias-and-db-type-arguments-are-req","errorCode":null,"errorMessage":"the <tablet alias> and <db type> arguments are required for the ChangeTabletType command","messagePattern":"the <tablet alias> and <db type> arguments are required for the ChangeTabletType command","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/vtctl.go","lineNumber":1139,"sourceCode":"\ttabletAlias, err := topoproto.ParseTabletAlias(subFlags.Arg(0))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = wr.VtctldServer().StopReplication(ctx, &vtctldatapb.StopReplicationRequest{\n\t\tTabletAlias: tabletAlias,\n\t})\n\treturn err\n}\n\nfunc commandChangeTabletType(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {\n\tdryRun := subFlags.Bool(\"dry-run\", false, \"Lists the proposed change without actually executing it\")\n\n\tif err := subFlags.Parse(args); err != nil {\n\t\treturn err\n\t}\n\tif subFlags.NArg() != 2 {\n\t\treturn errors.New(\"the <tablet alias> and <db type> arguments are required for the ChangeTabletType command\")\n\t}\n\n\ttabletAlias, err := topoproto.ParseTabletAlias(subFlags.Arg(0))\n\tif err != nil {\n\t\treturn err\n\t}\n\tnewType, err := parseTabletType(subFlags.Arg(1), topoproto.AllTabletTypes)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := context.WithTimeout(ctx, topo.RemoteOperationTimeout)\n\tdefer cancel()\n\n\tif *dryRun {\n\t\tti, err := wr.TopoServer().GetTablet(ctx, tabletAlias)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed reading tablet %v: %v\", tabletAlias, err)","sourceCodeStart":1121,"sourceCodeEnd":1157,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/vtctl.go#L1121-L1157","documentation":"This error is returned by the vtctl commandChangeTabletType handler when ChangeTabletType is not given exactly two positional arguments: a <tablet alias> and the target <db type> (e.g. replica, rdonly, spare). The handler enforces NArg() == 2 so both pieces are present before parsing the alias and tablet type.","triggerScenarios":"Running `vtctl ChangeTabletType` with fewer than two arguments (alias only, or nothing) or more than two (extra tokens). NArg() != 2 triggers the error.","commonSituations":"Omitting the target type because the user thinks it infers from context; passing an unquoted value that splits; passing the full type name variant in a way that adds an extra arg; scripts missing one of two variables.","solutions":["Re-run with both arguments: `vtctl ChangeTabletType zone1-0000000102 replica`.","Use a valid db type (replica, rdonly, spare, etc.) as the second argument, quoted if needed.","Verify both shell variables (alias and type) are set in scripts.","Check `vtctl ChangeTabletType --help` for the accepted type values."],"exampleFix":"// before\nvtctl ChangeTabletType zone1-0000000102\n// after\nvtctl ChangeTabletType zone1-0000000102 replica","handlingStrategy":"validation","validationCode":"alias=\"zone1-0000000102\"\ndbtype=\"replica\"\nif [ -z \"$alias\" ] || [ -z \"$dbtype\" ] || [ $# -ne 2 ]; then\n  echo \"usage: vtctl ChangeTabletType <tablet alias> <db type>\" >&2\n  exit 2\nfi\nvtctl ChangeTabletType \"$alias\" \"$dbtype\"","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"vtctl\", \"ChangeTabletType\", alias, dbType).CombinedOutput()\nif err != nil {\n    if strings.Contains(string(out), \"ChangeTabletType command\") {\n        return fmt.Errorf(\"need exactly 2 args (alias, dbType); got %d\", nArgs)\n    }\n    return err\n}","preventionTips":["Always pass two positional args: alias then target db type (replica, rdonly, spare).","Quote the db type so it stays a single token.","Verify both script variables are populated before invoking.","Check valid type names with --help before switching tablet types."],"tags":["vtctl","cli","missing-argument","tablet-type"],"backgroundTag":"missing-required-cli-argument","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}