Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check 'address' argument in add_host method #81

Open
gprossliner opened this issue Nov 19, 2019 · 0 comments
Open

Check 'address' argument in add_host method #81

gprossliner opened this issue Nov 19, 2019 · 0 comments

Comments

@gprossliner
Copy link

This is the current version of the 'add_host' method, called by Vagrantfiles:

https://github.com/oscar-stack/vagrant-hosts/blob/master/lib/vagrant-hosts/config.rb#L63-L69

There is no checking of the supplied arguments (see #80). If 'address' is nil, an invalid entry is stored within the '@hosts' list, causing the hosts provisioner to fail later with:

/home/USER/.vagrant.d/gems/2.4.4/gems/vagrant-hosts-2.9.0/lib/vagrant-hosts/addresses.rb:186:in `resolve_addresses': undefined method `start_with?' for nil:NilClass (NoMethodError)
	from /home/USER/.vagrant.d/gems/2.4.4/gems/vagrant-hosts-2.9.0/lib/vagrant-hosts/addresses.rb:137:in `block in resolve_host_entries'
	from /home/USER/.vagrant.d/gems/2.4.4/gems/vagrant-hosts-2.9.0/lib/vagrant-hosts/addresses.rb:135:in `each'
	from /home/USER/.vagrant.d/gems/2.4.4/gems/vagrant-hosts-2.9.0/lib/vagrant-hosts/addresses.rb:135:in `flat_map'
	from /home/USER/.vagrant.d/gems/2.4.4/gems/vagrant-hosts-2.9.0/lib/vagrant-hosts/addresses.rb:135:in `resolve_host_entries'
	from /home/USER/.vagrant.d/gems/2.4.4/gems/vagrant-hosts-2.9.0/lib/vagrant-hosts/addresses.rb:34:in `all_hosts'
	from /home/USER/.vagrant.d/gems/2.4.4/gems/vagrant-hosts-2.9.0/lib/vagrant-hosts/cap/sync_hosts/posix.rb:34:in `format_hosts'
	from /home/USER/.vagrant.d/gems/2.4.4/gems/vagrant-hosts-2.9.0/lib/vagrant-hosts/cap/sync_hosts/posix.rb:11:in `update_hosts'
	from /home/USER/.vagrant.d/gems/2.4.4/gems/vagrant-hosts-2.9.0/lib/vagrant-hosts/cap/sync_hosts/base.rb:31:in `sync!'
	from /home/USER/.vagrant.d/gems/2.4.4/gems/vagrant-hosts-2.9.0/lib/vagrant-hosts/cap/sync_hosts/base.rb:11:in `sync_hosts'
	from /opt/vagrant/embedded/gems/2.2.4/gems/vagrant-2.2.4/lib/vagrant/capability_host.rb:111:in `call'
...

This is not the expected behavior, and it's hard to diagnose. I would expect the error to be raised when calling the add_host method, to get a reasonable stack trace, or even a message in vagrant validate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant