{"record":{"id":"f76d38d554697052","repo":"vitessio/vitess","slug":"the-alias-argument-is-required-for-the-addcellsa","errorCode":null,"errorMessage":"the <alias> argument is required for the AddCellsAlias command","messagePattern":"the <alias> argument is required for the AddCellsAlias command","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/cells_aliases.go","lineNumber":74,"sourceCode":"\t\tparams: \"<alias>\",\n\t\thelp:   \"Deletes the CellsAlias for the provided alias.\",\n\t})\n\n\taddCommand(cellsAliasesGroupName, command{\n\t\tname:   \"GetCellsAliases\",\n\t\tmethod: commandGetCellsAliases,\n\t\tparams: \"\",\n\t\thelp:   \"Lists all the cells for which we have a CellsAlias object.\",\n\t})\n}\n\nfunc commandAddCellsAlias(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {\n\tcells := subFlags.StringSlice(\"cells\", nil, \"The list of cell names that are members of this alias.\")\n\tif err := subFlags.Parse(args); err != nil {\n\t\treturn err\n\t}\n\tif subFlags.NArg() != 1 {\n\t\treturn errors.New(\"the <alias> argument is required for the AddCellsAlias command\")\n\t}\n\n\tfor i, cell := range *cells {\n\t\t(*cells)[i] = strings.TrimSpace(cell)\n\t}\n\n\talias := subFlags.Arg(0)\n\t_, err := wr.VtctldServer().AddCellsAlias(ctx, &vtctldatapb.AddCellsAliasRequest{\n\t\tName:  alias,\n\t\tCells: *cells,\n\t})\n\treturn err\n}\n\nfunc commandUpdateCellsAlias(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.FlagSet, args []string) error {\n\tcells := subFlags.StringSlice(\"cells\", nil, \"The list of cell names that are members of this alias.\")\n\tif err := subFlags.Parse(args); err != nil {\n\t\treturn err","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/cells_aliases.go#L56-L92","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Re-run as `vtctldclient AddCellsAlias --cells <cell1,cell2,...> <alias>`","Provide member cells only through the --cells flag","Quote the alias to keep it a single positional argument"],"exampleFix":"// before\nvtctldclient AddCellsAlias --cells zone1,zone2\n// after\nvtctldclient AddCellsAlias --cells zone1,zone2 dcalias","handlingStrategy":"validation","validationCode":"args := flagSet.Args()\ncells := flagSet.GetStringSlice(\"cells\", nil)\nif len(args) != 1 || len(cells) == 0 {\n    return errors.New(\"the <alias> argument is required for the AddCellsAlias command\")\n}\nalias := args[0]","typeGuard":"func hasExactlyOneArg(args []string) bool { return len(args) == 1 }","tryCatchPattern":"if err := commandAddCellsAlias(ctx, wr, subFlags, args); err != nil {\n    if strings.Contains(err.Error(), \"the <alias> argument is required\") {\n        log.Printf(\"usage: AddCellsAlias --cells <cell1,cell2,...> <alias>\")\n    }\n    return err\n}","preventionTips":["Member cells always go in --cells, never positionally","Quote the alias as a single token","Create the alias once with AddCellsAlias before UpdateCellsAlias"],"tags":["cli","argument-validation","topology","cells-alias"],"backgroundTag":"missing-required-argument","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}