Treat an empty box value as invalid

This fixes an issue where having a box name set to an empty string will
cause all Vagrant commands to fail with an error like:

ArgumentError: Malformed version number string (random box name)

This may be related to #10663.
This commit is contained in:
Jeff Bonhag 2020-05-13 16:32:40 -04:00
parent 6ee180a023
commit 352b955d09
No known key found for this signature in database
GPG Key ID: 32966F3FB5AC1129
2 changed files with 7 additions and 1 deletions

View File

@ -511,7 +511,7 @@ module VagrantPlugins
@base_mac = nil if @base_mac == UNSET_VALUE
@base_address = nil if @base_address == UNSET_VALUE
@boot_timeout = 300 if @boot_timeout == UNSET_VALUE
@box = nil if @box == UNSET_VALUE
@box = nil if @box == UNSET_VALUE || @box.to_s.empty?
@ignore_box_vagrantfile = false if @ignore_box_vagrantfile == UNSET_VALUE
if @box_check_update == UNSET_VALUE

View File

@ -86,6 +86,12 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
assert_invalid
end
it "cannot be an empty string" do
subject.box = ""
subject.finalize!
assert_invalid
end
it "is not required if the provider says so" do
machine.provider_options[:box_optional] = true
subject.box = nil