vitessio/vitess · error

the <alias> argument is required for the AddCellsAlias comma

Error message

the <alias> argument is required for the AddCellsAlias command

What it means

commandAddCellsAlias creates a cells alias grouping multiple cells and requires exactly one positional argument: the alias name. Member cells are provided via the --cells flag, not positionally. The error is returned when subFlags.NArg() != 1.

Source

Thrown at go/vt/vtctl/cells_aliases.go:74

		params: "<alias>",
		help:   "Deletes the CellsAlias for the provided alias.",
	})

	addCommand(cellsAliasesGroupName, command{
		name:   "GetCellsAliases",
		method: commandGetCellsAliases,
		params: "",
		help:   "Lists all the cells for which we have a CellsAlias object.",
	})
}

func commandAddCellsAlias(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
	cells := subFlags.StringSlice("cells", nil, "The list of cell names that are members of this alias.")
	if err := subFlags.Parse(args); err != nil {
		return err
	}
	if subFlags.NArg() != 1 {
		return errors.New("the <alias> argument is required for the AddCellsAlias command")
	}

	for i, cell := range *cells {
		(*cells)[i] = strings.TrimSpace(cell)
	}

	alias := subFlags.Arg(0)
	_, err := wr.VtctldServer().AddCellsAlias(ctx, &vtctldatapb.AddCellsAliasRequest{
		Name:  alias,
		Cells: *cells,
	})
	return err
}

func commandUpdateCellsAlias(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {
	cells := subFlags.StringSlice("cells", nil, "The list of cell names that are members of this alias.")
	if err := subFlags.Parse(args); err != nil {
		return err

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Re-run as `vtctldclient AddCellsAlias --cells <cell1,cell2,...> <alias>`
  2. Provide member cells only through the --cells flag
  3. Quote the alias to keep it a single positional argument

Example fix

// before
vtctldclient AddCellsAlias --cells zone1,zone2
// after
vtctldclient AddCellsAlias --cells zone1,zone2 dcalias
Defensive patterns

Strategy: validation

Validate before calling

args := flagSet.Args()
cells := flagSet.GetStringSlice("cells", nil)
if len(args) != 1 || len(cells) == 0 {
    return errors.New("the <alias> argument is required for the AddCellsAlias command")
}
alias := args[0]

Type guard

func hasExactlyOneArg(args []string) bool { return len(args) == 1 }

Try / catch

if err := commandAddCellsAlias(ctx, wr, subFlags, args); err != nil {
    if strings.Contains(err.Error(), "the <alias> argument is required") {
        log.Printf("usage: AddCellsAlias --cells <cell1,cell2,...> <alias>")
    }
    return err
}

Prevention

When it happens

Trigger: Running `vtctldclient AddCellsAlias --cells a,b` with no alias positional argument, or listing member cells positionally instead of via --cells (which makes NArg exceed 1).

Common situations: Passing the alias as a flag value by mistake; supplying cell names as positional arguments instead of the --cells flag; empty alias variable in automation.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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