{"record":{"id":"edd5c9a53f41ddcd","repo":"vitessio/vitess","slug":"cluster-name-needs-to-be-provided","errorCode":null,"errorMessage":"cluster name needs to be provided","messagePattern":"cluster name needs to be provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/vtctl.go","lineNumber":3870,"sourceCode":"\n\t// vitess cluster params\n\ttopoType := subFlags.String(\"topo_type\", \"\", \"Type of cluster's topology server\")\n\ttopoServer := subFlags.String(\"topo_server\", \"\", \"Server url of cluster's topology server\")\n\ttopoRoot := subFlags.String(\"topo_root\", \"\", \"Root node of cluster's topology\")\n\n\tif err := subFlags.Parse(args); err != nil {\n\t\treturn err\n\t}\n\tif *list {\n\t\tclusters, err := wr.TopoServer().GetExternalVitessClusters(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\twr.Logger().Printf(\"%s\\n\", strings.Join(clusters, \",\"))\n\t\treturn nil\n\t}\n\tif subFlags.NArg() != 1 {\n\t\treturn errors.New(\"cluster name needs to be provided\")\n\t}\n\n\tclusterName := subFlags.Arg(0)\n\tswitch *clusterType {\n\tcase \"vitess\":\n\t\tswitch {\n\t\tcase *unmount:\n\t\t\treturn wr.UnmountExternalVitessCluster(ctx, clusterName)\n\t\tcase *show:\n\t\t\tvci, err := wr.TopoServer().GetExternalVitessCluster(ctx, clusterName)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif vci == nil {\n\t\t\t\treturn fmt.Errorf(\"there is no vitess cluster named %s\", clusterName)\n\t\t\t}\n\t\t\tdata, err := json.Marshal(vci)\n\t\t\tif err != nil {","sourceCodeStart":3852,"sourceCodeEnd":3888,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/vtctl.go#L3852-L3888","documentation":"This error is returned by a vtctl cluster-related command handler when no cluster name positional argument is supplied. The surrounding code supports listing clusters (printing joined cluster names and returning early), but if the list path is not taken it requires exactly one argument naming the cluster to operate on. The handler validates NArg() == 1 before branching on --cluster-type (e.g. vitess).","triggerScenarios":"Running the cluster command (e.g. with --cluster-type vitess) without the cluster name positional argument, or with more than one positional argument (NArg() != 1).","commonSituations":"Omitting the cluster name while setting --cluster-type; scripts where the cluster name variable is empty; confusing the flag-based type with the positional name and passing both as flags.","solutions":["Re-run providing exactly one cluster name: e.g. `vtctl <command> --cluster-type vitess mycluster`.","Verify the cluster name matches a configured cluster.","If you intended to list clusters, use the list invocation (no positional args) rather than passing a partial command.","Check the command's --help for the list-vs-act usage."],"exampleFix":"// before\nvtctl AddCluster --cluster-type vitess\n// after\nvtctl AddCluster --cluster-type vitess mycluster","handlingStrategy":"validation","validationCode":"cluster=\"mycluster\"\nif [ -z \"$cluster\" ] || [ $# -ne 1 ]; then\n  echo \"usage: vtctl <cluster command> --cluster-type <type> <cluster name>\" >&2\n  exit 2\nfi\nvtctl \"$command\" --cluster-type vitess \"$cluster\"","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"vtctl\", cmd, \"--cluster-type\", \"vitess\", cluster).CombinedOutput()\nif err != nil {\n    if strings.Contains(string(out), \"cluster name needs to be provided\") {\n        return fmt.Errorf(\"cluster command requires exactly one cluster-name positional arg\")\n    }\n    return err\n}","preventionTips":["Always supply the cluster name as the single positional argument when acting on a cluster.","Use the no-argument list form if you only want to enumerate clusters.","Ensure the cluster name variable is set in scripts.","Pass the type via --cluster-type flag, not as a positional argument."],"tags":["vtctl","cli","missing-argument","cluster"],"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"}