{"record":{"id":"dad550dece6d6aed","repo":"hashicorp/vagrant","slug":"an-unexpected-error-occurred-error","errorCode":null,"errorMessage":"An unexpected error occurred: %{error}","messagePattern":"An unexpected error occurred: %(.+?)","errorType":"exception","errorClass":"VagrantPlugins::CloudCommand::Errors::Unexpected","httpStatus":null,"severity":"error","filePath":"plugins/commands/cloud/client/client.rb","lineNumber":184,"sourceCode":"        if !t.nil?\n          Vagrant::Util::CredentialScrubber.sensitive(t)\n          return t\n        end\n\n        @logger.debug(\"No authentication token in environment or #{token_path}\")\n\n        nil\n      end\n\n      protected\n\n      def with_error_handling(&block)\n        yield\n      rescue VagrantCloud::Error::ClientError => e\n        @logger.debug(\"vagrantcloud request error:\")\n        @logger.debug(e.message)\n        @logger.debug(e.backtrace.join(\"\\n\"))\n        raise Errors::Unexpected, error: e.message\n      rescue Excon::Error::Unauthorized\n        @logger.debug(\"Unauthorized!\")\n        raise Errors::Unauthorized\n      rescue Excon::Error::BadRequest => e\n        @logger.debug(\"Bad request:\")\n        @logger.debug(e.message)\n        @logger.debug(e.backtrace.join(\"\\n\"))\n        parsed_response = JSON.parse(e.response.body)\n        errors = parsed_response[\"errors\"].join(\"\\n\")\n        raise Errors::ServerError, errors: errors\n      rescue Excon::Error::NotAcceptable => e\n        @logger.debug(\"Got unacceptable response:\")\n        @logger.debug(e.message)\n        @logger.debug(e.backtrace.join(\"\\n\"))\n\n        parsed_response = JSON.parse(e.response.body)\n\n        if two_factor = parsed_response['two_factor']","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/commands/cloud/client/client.rb#L166-L202","documentation":"Vagrant::Errors::Unexpected is the catch-all of the cloud client wrapper's `with_error_handling`: any VagrantCloud::Error::ClientError raised by the vagrant-cloud gem during an API call — i.e. a failure this wrapper does not map to Unauthorized, BadRequest, NotAcceptable, or SocketError — is re-raised as Unexpected carrying the original message. The underlying message and backtrace are logged only at debug level, so the default output gives no cause.","triggerScenarios":"Any `vagrant cloud ...` command that performs an API request (auth login/logout, whoami, box/version/provider CRUD, publish, search) and receives an error response outside the specifically handled set, or any gem-level client failure inside VagrantCloud::Account / VagrantCloud::Box operations.","commonSituations":"A Vagrant Cloud incident returning 5xx; a vagrant-cloud gem version bundled with an older Vagrant speaking an out-of-date API; a malformed or expired token producing an unmapped 4xx; a custom VAGRANT_SERVER_URL returning unexpected payloads.","solutions":["Re-run with debug logging to surface the swallowed cause: `VAGRANT_LOG=debug vagrant cloud auth whoami 2>&1 | grep -A20 'vagrantcloud request error'`","Verify auth state with `vagrant cloud auth whoami` and re-login (`vagrant cloud auth login`) if the token is stale","Upgrade Vagrant so the bundled vagrant-cloud gem matches the current API","Check https://status.hashicorp.com for a Vagrant Cloud incident, then retry"],"exampleFix":"# before\nvagrant cloud box create myorg/mybox\n# after (surface the hidden underlying error and backtrace)\nVAGRANT_LOG=debug vagrant cloud box create myorg/mybox 2>&1 | grep -A20 'vagrantcloud request error'","handlingStrategy":"try-catch","validationCode":"# Cheap preflight before a batch of cloud commands\nrequire \"excon\"\nbegin\n  Excon.get(ENV[\"VAGRANT_SERVER_URL\"] || \"https://vagrantcloud.com\", timeout: 5)\nrescue Excon::Error => e\n  abort \"Vagrant Cloud preflight failed: #{e.class} — fix connectivity before running cloud commands\"\nend","typeGuard":"# Distinguish the catch-all from specific cloud errors before handling\ndef unexpected_cloud_error?(e)\n  e.is_a?(Vagrant::Errors::Unexpected)\nend","tryCatchPattern":"begin\n  client.whoami(token)\nrescue Vagrant::Errors::Unexpected => e\n  # default output hides the cause; log it and re-raise or alert\n  logger.fatal(\"vagrant cloud call failed: #{e.message}\")\n  raise\nend","preventionTips":["Run cloud commands with VAGRANT_LOG=debug when integrating, so the swallowed cause is visible","Pin a Vagrant release whose bundled vagrant-cloud gem matches the API you target","Treat any Unexpected in CI as a signal to check token validity and Vagrant Cloud status"],"tags":["vagrant","vagrant-cloud","api","http-client","error-handling"],"backgroundTag":"api-client-error","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}