vitessio/vitess · error

the <tablet alias> and <db type> arguments are required for

Error message

the <tablet alias> and <db type> arguments are required for the ChangeTabletType command

What it means

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.

Source

Thrown at go/vt/vtctl/vtctl.go:1139

	tabletAlias, err := topoproto.ParseTabletAlias(subFlags.Arg(0))
	if err != nil {
		return err
	}

	_, err = wr.VtctldServer().StopReplication(ctx, &vtctldatapb.StopReplicationRequest{
		TabletAlias: tabletAlias,
	})
	return err
}

func commandChangeTabletType(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
	dryRun := subFlags.Bool("dry-run", false, "Lists the proposed change without actually executing it")

	if err := subFlags.Parse(args); err != nil {
		return err
	}
	if subFlags.NArg() != 2 {
		return errors.New("the <tablet alias> and <db type> arguments are required for the ChangeTabletType command")
	}

	tabletAlias, err := topoproto.ParseTabletAlias(subFlags.Arg(0))
	if err != nil {
		return err
	}
	newType, err := parseTabletType(subFlags.Arg(1), topoproto.AllTabletTypes)
	if err != nil {
		return err
	}

	ctx, cancel := context.WithTimeout(ctx, topo.RemoteOperationTimeout)
	defer cancel()

	if *dryRun {
		ti, err := wr.TopoServer().GetTablet(ctx, tabletAlias)
		if err != nil {
			return fmt.Errorf("failed reading tablet %v: %v", tabletAlias, err)

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Re-run with both arguments: `vtctl ChangeTabletType zone1-0000000102 replica`.
  2. Use a valid db type (replica, rdonly, spare, etc.) as the second argument, quoted if needed.
  3. Verify both shell variables (alias and type) are set in scripts.
  4. Check `vtctl ChangeTabletType --help` for the accepted type values.

Example fix

// before
vtctl ChangeTabletType zone1-0000000102
// after
vtctl ChangeTabletType zone1-0000000102 replica
Defensive patterns

Strategy: validation

Validate before calling

alias="zone1-0000000102"
dbtype="replica"
if [ -z "$alias" ] || [ -z "$dbtype" ] || [ $# -ne 2 ]; then
  echo "usage: vtctl ChangeTabletType <tablet alias> <db type>" >&2
  exit 2
fi
vtctl ChangeTabletType "$alias" "$dbtype"

Try / catch

out, err := exec.Command("vtctl", "ChangeTabletType", alias, dbType).CombinedOutput()
if err != nil {
    if strings.Contains(string(out), "ChangeTabletType command") {
        return fmt.Errorf("need exactly 2 args (alias, dbType); got %d", nArgs)
    }
    return err
}

Prevention

When it happens

Trigger: Running `vtctl ChangeTabletType` with fewer than two arguments (alias only, or nothing) or more than two (extra tokens). NArg() != 2 triggers the error.

Common situations: 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.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/f51ec6d8cf1b979f. Report an issue: GitHub.