From ac0d213c9b0b40619d4af075dd018aec4a78e449 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 6 Aug 2014 13:00:29 -0700 Subject: [PATCH] core: fix crash case with provisioners [GH-4281] --- CHANGELOG.md | 1 + lib/vagrant/action/builtin/mixin_provisioners.rb | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dde07259..95a63d244 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ BUG FIXES: - core: Windows is not detected as NixOS in some cases. [GH-4302] - core: Fix encoding issues with Windows. There are still some outlying but this fixes a few. [GH-4159] + - core: Fix crash case when destroying with an invalid provisioner. [GH-4281] - commands/package: base package won't crash with exception [GH-4017] - communicators/winrm: Support `mkdir` [GH-4271] - guests/centos: Fix issues when NFS client is installed by restarting diff --git a/lib/vagrant/action/builtin/mixin_provisioners.rb b/lib/vagrant/action/builtin/mixin_provisioners.rb index c04536c12..9ee465aa5 100644 --- a/lib/vagrant/action/builtin/mixin_provisioners.rb +++ b/lib/vagrant/action/builtin/mixin_provisioners.rb @@ -16,6 +16,10 @@ module Vagrant @_provisioner_instances = env[:machine].config.vm.provisioners.map do |provisioner| # Instantiate the provisioner klass = Vagrant.plugin("2").manager.provisioners[provisioner.name] + + # This can happen in the case the configuration isn't validated. + next nil if !klass + result = klass.new(env[:machine], provisioner.config) # Store in the type map so that --provision-with works properly @@ -30,7 +34,7 @@ module Vagrant [result, options] end - return @_provisioner_instances + return @_provisioner_instances.compact end # This will return a mapping of a provisioner instance to its