From 947db2304a4f64ffc3dfb83dac996f5393b9b74d Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 28 Apr 2017 21:58:55 -0400 Subject: [PATCH] it's possible to get a nil diff in PreApply Looking through the operations in node_resource_apply and node_resource_destroy, there are multiple nil checks for diffApply, so one we need to continue to assume that the diff can be nil through there until we ensure that it is non-nill in all cases. So regardless of how we came to get a nil diff in the UiHook PreApply method, we need to check it. --- command/hook_count.go | 4 ++++ command/hook_ui.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/command/hook_count.go b/command/hook_count.go index 150ae438e..127284d34 100644 --- a/command/hook_count.go +++ b/command/hook_count.go @@ -42,6 +42,10 @@ func (h *CountHook) PreApply( h.Lock() defer h.Unlock() + if d.Empty() { + return terraform.HookActionContinue, nil + } + if h.pending == nil { h.pending = make(map[string]countHookAction) } diff --git a/command/hook_ui.go b/command/hook_ui.go index 8d8f4539e..a53edfa38 100644 --- a/command/hook_ui.go +++ b/command/hook_ui.go @@ -59,6 +59,11 @@ func (h *UiHook) PreApply( d *terraform.InstanceDiff) (terraform.HookAction, error) { h.once.Do(h.init) + // if there's no diff, there's nothing to output + if d.Empty() { + return terraform.HookActionContinue, nil + } + id := n.HumanId() op := uiResourceModify