Merge pull request #9760 from briancain/continue-on-malformed-json

Continue on if vagrant fails to parse metadata box for update
This commit is contained in:
Brian Cain 2018-05-02 15:49:08 -07:00 committed by GitHub
commit 70df6d4b2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -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(

View File

@ -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: |-

View File

@ -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)