diff --git a/terraform/eval_refresh.go b/terraform/eval_refresh.go index 1d4e87af0..a13ef5de7 100644 --- a/terraform/eval_refresh.go +++ b/terraform/eval_refresh.go @@ -4,6 +4,8 @@ import ( "fmt" "log" + "github.com/zclconf/go-cty/cty" + "github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/providers" "github.com/hashicorp/terraform/states" @@ -62,6 +64,13 @@ func (n *EvalRefresh) Eval(ctx EvalContext) (interface{}, error) { return nil, diags.Err() } + if resp.NewState == cty.NilVal { + // This ought not to happen in real cases since it's not possible to + // send NilVal over the plugin RPC channel, but it can come up in + // tests due to sloppy mocking. + panic("new state is cty.NilVal") + } + for _, err := range schema.ImpliedType().TestConformance(resp.NewState.Type()) { diags = diags.Append(tfdiags.Sourceless( tfdiags.Error,