core: Fix error reporting for malformed provider response values
This commit is contained in:
parent
630b0d147d
commit
d54b52fa01
|
@ -76,13 +76,13 @@ func (n *EvalApply) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
// incomplete.
|
// incomplete.
|
||||||
newVal := resp.NewState
|
newVal := resp.NewState
|
||||||
|
|
||||||
for _, err := range schema.ImpliedType().TestConformance(newVal.Type()) {
|
for _, err := range newVal.Type().TestConformance(schema.ImpliedType()) {
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Provider produced invalid object",
|
"Provider produced invalid object",
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"Provider %q planned an invalid value for %s%s after apply, and so the result could not be saved.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.",
|
"Provider %q planned an invalid value after apply for %s. The result could not be saved.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.",
|
||||||
n.ProviderAddr.ProviderConfig.Type, absAddr, tfdiags.FormatError(err),
|
n.ProviderAddr.ProviderConfig.Type, tfdiags.FormatErrorPrefixed(err, absAddr.String()),
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,13 +153,13 @@ func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
// here, since that allows the provider to do special logic like a
|
// here, since that allows the provider to do special logic like a
|
||||||
// DiffSuppressFunc, but we still require that the provider produces
|
// DiffSuppressFunc, but we still require that the provider produces
|
||||||
// a value whose type conforms to the schema.
|
// a value whose type conforms to the schema.
|
||||||
for _, err := range schema.ImpliedType().TestConformance(plannedNewVal.Type()) {
|
for _, err := range plannedNewVal.Type().TestConformance(schema.ImpliedType()) {
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Provider produced invalid plan",
|
"Provider produced invalid plan",
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"Provider %q planned an invalid value for %s%s.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.",
|
"Provider %q planned an invalid value for %s.\n\nThis is a bug in the provider, which should be reported in the provider's own issue tracker.",
|
||||||
n.ProviderAddr.ProviderConfig.Type, absAddr, tfdiags.FormatError(err),
|
n.ProviderAddr.ProviderConfig.Type, tfdiags.FormatErrorPrefixed(err, absAddr.String()),
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ func (n *EvalReadState) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
schema := (*n.ProviderSchema).ResourceTypes[absAddr.Resource.Resource.Type]
|
schema := (*n.ProviderSchema).SchemaForResourceAddr(n.Addr.ContainingResource())
|
||||||
obj, err := src.Decode(schema.ImpliedType())
|
obj, err := src.Decode(schema.ImpliedType())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -103,7 +103,7 @@ func (n *EvalReadStateDeposed) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
schema := (*n.ProviderSchema).ResourceTypes[absAddr.Resource.Resource.Type]
|
schema := (*n.ProviderSchema).SchemaForResourceAddr(n.Addr.ContainingResource())
|
||||||
obj, err := src.Decode(schema.ImpliedType())
|
obj, err := src.Decode(schema.ImpliedType())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue