{"record":{"id":"a76d2e4ec7dcd738","repo":"hashicorp/vagrant","slug":"this-command-was-not-invoked-properly-the-help-fo-a76d2e","errorCode":null,"errorMessage":"This command was not invoked properly. The help for this command is\navailable below.\n\n%{help}","messagePattern":"This command was not invoked properly\\. The help for this command is\navailable below\\.\n\n%(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::CLIInvalidUsage","httpStatus":null,"severity":"error","filePath":"plugins/commands/cloud/auth/whoami.rb","lineNumber":26,"sourceCode":"    module AuthCommand\n      module Command\n        class Whoami < Vagrant.plugin(\"2\", :command)\n          include Util\n\n          def execute\n            options = {}\n\n            opts = OptionParser.new do |o|\n              o.banner = \"Usage: vagrant cloud auth whoami [token]\"\n              o.separator \"\"\n              o.separator \"Display currently logged in user\"\n            end\n\n            # Parse the options\n            argv = parse_options(opts)\n            return if !argv\n            if argv.size > 1\n              raise Vagrant::Errors::CLIInvalidUsage,\n                help: opts.help.chomp\n            end\n\n            if argv.first\n              token = argv.first\n            else\n              client = Client.new(@env)\n              token = client.token\n            end\n\n            whoami(token)\n          end\n\n          def whoami(access_token)\n            if access_token.to_s.empty?\n              @env.ui.error(I18n.t(\"cloud_command.check_not_logged_in\"))\n              return 1\n            end","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/commands/cloud/auth/whoami.rb#L8-L44","documentation":"Vagrant raises Vagrant::Errors::CLIInvalidUsage when `vagrant cloud auth whoami` receives more than one positional argument. The command accepts either zero arguments (it then reads the token stored by `vagrant cloud auth login`) or exactly one argument (an explicit access token). Any other count is a usage error, and the message re-prints the command's OptionParser help so the correct invocation is visible.","triggerScenarios":"Running `vagrant cloud auth whoami <token> <extra-arg>`, or any invocation where argv.size > 1 after option parsing. An unquoted shell variable containing whitespace splits into multiple argv entries and triggers it.","commonSituations":"Copy-pasting a command written for a different CLI that expects username plus token; shell scripts that append arguments unconditionally; passing an unquoted $TOKEN that expands to more than one word.","solutions":["Run `vagrant cloud auth whoami` with no arguments to use the stored token, or with exactly one token argument","Quote the token so it cannot split: `vagrant cloud auth whoami \"$VAGRANT_CLOUD_TOKEN\"`","Run `vagrant cloud auth whoami -h` to confirm the exact usage banner"],"exampleFix":"# before\nvagrant cloud auth whoami mytoken extra-arg\n# after\nvagrant cloud auth whoami mytoken\n# or use the token stored by `vagrant cloud auth login`\nvagrant cloud auth whoami","handlingStrategy":"validation","validationCode":"# bash: enforce the 0-or-1 argument contract before invoking vagrant\nif [ \"$#\" -gt 1 ]; then\n  echo \"usage: vagrant cloud auth whoami [token]\" >&2\n  exit 64\nfi\nexec vagrant cloud auth whoami \"$@\"","typeGuard":"# Ruby: Vagrant signals usage problems by error class — narrow before handling\ndef cli_usage_error?(e)\n  e.is_a?(Vagrant::Errors::CLIInvalidUsage)\nend","tryCatchPattern":"begin\n  env.cli(%w[cloud auth whoami], *args)\nrescue Vagrant::Errors::CLIInvalidUsage => e\n  # e.message already embeds the full help; log only the banner line\n  $stderr.puts e.message.lines.first\n  exit 64\nend","preventionTips":["Count arguments in wrapper scripts before calling vagrant","Always quote expanded variables passed as a single CLI argument","Run an unfamiliar cloud subcommand with -h first to learn its positional contract"],"tags":["vagrant","vagrant-cloud","cli","argument-validation"],"backgroundTag":"cli-invalid-usage","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}