diff --git a/lib/vagrant/action/builtin/box_check_outdated.rb b/lib/vagrant/action/builtin/box_check_outdated.rb index afb8b7368..8212c669a 100644 --- a/lib/vagrant/action/builtin/box_check_outdated.rb +++ b/lib/vagrant/action/builtin/box_check_outdated.rb @@ -58,6 +58,9 @@ module Vagrant env[:ui].warn(I18n.t( "vagrant.box_outdated_metadata_download_error", message: e.extra_data[:message])) + rescue Errors::BoxMetadataMalformed => e + @logger.warn(e.to_s) + env[:ui].warn(I18n.t("vagrant.box_malformed_continue_on_update")) rescue Errors::VagrantError => e raise if !env[:box_outdated_ignore_errors] env[:ui].detail(I18n.t( diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 4cc23771e..b068bd17a 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -40,6 +40,9 @@ en: URL: %{url} box_loading_metadata: |- Loading metadata for box '%{name}' + box_malformed_continue_on_update: |- + Could not determine box updates because box metadata was malformed. + Vagrant will continue on... box_outdated: |- * '%{name}' for '%{provider}' is outdated! Current: %{current}. Latest: %{latest} box_outdated_checking_with_refresh: |- diff --git a/test/unit/vagrant/action/builtin/box_check_outdated_test.rb b/test/unit/vagrant/action/builtin/box_check_outdated_test.rb index 82aa25e1a..058684467 100644 --- a/test/unit/vagrant/action/builtin/box_check_outdated_test.rb +++ b/test/unit/vagrant/action/builtin/box_check_outdated_test.rb @@ -166,6 +166,17 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do expect(env[:box_outdated]).to be(false) end + it "does nothing if metadata cannot be parsed" do + expect(box).to receive(:has_update?).and_raise( + Vagrant::Errors::BoxMetadataMalformed.new(error: "Whoopsie")) + + expect(app).to receive(:call).once + + subject.call(env) + + expect(env[:box_outdated]).to be(false) + end + it "raises error if has_update? errors" do expect(box).to receive(:has_update?).and_raise(Vagrant::Errors::VagrantError)