core: Better error message for faulty provider in EvalRefresh

This commit is contained in:
Martin Atkins 2018-09-07 14:53:36 -07:00
parent 297f1019d5
commit a8d62478c6
1 changed files with 9 additions and 0 deletions

View File

@ -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,