{"record":{"id":"7cceb639b0abd876","repo":"vitessio/vitess","slug":"no-command-was-specified","errorCode":null,"errorMessage":"no command was specified","messagePattern":"no command was specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/vtctl.go","lineNumber":4005,"sourceCode":"\t\t}\n\tdefault:\n\t\tdata, err = json.MarshalIndent(obj, \"\", \"  \")\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"json error: %v\", err)\n\t\t}\n\t}\n\n\treturn data, nil\n}\n\n// RunCommand will execute the command using the provided wrangler.\n// It will return the actionPath to wait on for long remote actions if\n// applicable.\nfunc RunCommand(ctx context.Context, wr *wrangler.Wrangler, args []string) error {\n\tif len(args) == 0 {\n\t\twr.Logger().Printf(\"No command specified. Please see the list below:\\n\\n\")\n\t\tPrintAllCommands(wr.Logger())\n\t\treturn errors.New(\"no command was specified\")\n\t}\n\n\taction := args[0]\n\tactionLowerCase := strings.ToLower(action)\n\tfor _, group := range commands {\n\t\tfor _, cmd := range group.commands {\n\t\t\tif strings.ToLower(cmd.name) == actionLowerCase {\n\t\t\t\tsubFlags := pflag.NewFlagSet(action, pflag.ContinueOnError)\n\t\t\t\tsubFlags.SetOutput(logutil.NewLoggerWriter(wr.Logger()))\n\t\t\t\tsubFlags.Usage = func() {\n\t\t\t\t\tif cmd.deprecated {\n\t\t\t\t\t\tmsg := &strings.Builder{}\n\t\t\t\t\t\tmsg.WriteString(\"WARNING: \")\n\t\t\t\t\t\tmsg.WriteString(action)\n\t\t\t\t\t\tmsg.WriteString(\" is deprecated and will be removed in a future release.\")\n\t\t\t\t\t\tif cmd.deprecatedBy != \"\" {\n\t\t\t\t\t\t\tmsg.WriteString(\" Use \")\n\t\t\t\t\t\t\tmsg.WriteString(cmd.deprecatedBy)","sourceCodeStart":3987,"sourceCodeEnd":4023,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/vtctl.go#L3987-L4023","documentation":"RunCommand validates that at least one command argument was supplied to vtctl. When args is empty it prints the full command list to help the user, then returns this error. It is a usage error, not an internal failure.","triggerScenarios":"Invoking vtctl without a command (e.g. `vtctl --topo_server ... --topo_root ...` with no command name), or passing only flags so args[0] is missing after flag parsing.","commonSituations":"Scripts that lost their positional argument due to variable expansion failures ($CMD empty); calling the vtctl library RunCommand directly with an empty slice; wrappers that swallow the command.","solutions":["Supply a command as the first positional argument, e.g. `vtctl GetKeyspace commerce`","Check shell scripts for empty variables feeding the command name","Review the printed command list (or `vtctl --help`) to pick the correct command"],"exampleFix":"// before\nvtctl $FLAGS   # CMD variable was empty\n// after\nvtctl $FLAGS GetKeyspace commerce","handlingStrategy":"validation","validationCode":"if len(args) == 0 {\n    return fmt.Errorf(\"usage: vtctl [global flags] <command> [args...]\")\n}","typeGuard":null,"tryCatchPattern":"if err := vtctl.RunCommand(ctx, wr, args); err != nil {\n    if strings.Contains(err.Error(), \"no command was specified\") {\n        vtctl.PrintAllCommands(logger)\n    }\n    return err\n}","preventionTips":["Quote and default-check shell variables supplying the command name","Wrap vtctl in a script that asserts $# >= 1 command argument","Run `vtctl --help` when unsure of command names"],"tags":["vtctl","cli","usage-error","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}