I’m working with framework 0.11.1, and am stuck looking at a problem where my resource Create()
method encounters an error almost immediately.
The error summary is:
Value Conversion Error
The error detail says:
An unexpected error was encountered trying to build a value.
This is always an error in the provider.
Please report the following to the provider developer:
unhandled unknown value
The error occurs right at the beginning of the Create()
function, when it fetches the plan:
plan := &ResourceMyThing{}
diags := req.Plan.Get(ctx, plan) // <--- the error is produced right here
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
Given that there’s no state, and almost none of my code has run yet, I’m guessing it’s a problem with how I’ve set up the schema.
GetSchema ()
returns the following:
return tfsdk.Schema{
Attributes: map[string]tfsdk.Attribute{
"name": {
Type: types.StringType,
Required: true,
Validators: []tfsdk.AttributeValidator{stringvalidator.LengthAtLeast(1)},
},
"nested_set": {
Required: true,
Attributes: tfsdk.SetNestedAttributes(map[string]tfsdk.Attribute{
"name": {
Type: types.StringType,
Required: true,
Validators: []tfsdk.AttributeValidator{stringvalidator.LengthAtLeast(1)},
},
"problem_netsted_list": {
Computed: true,
Attributes: tfsdk.ListNestedAttributes(map[string]tfsdk.Attribute{
"attr_1": {
Computed: true,
Type: types.Int64Type,
},
"attr_2": {
Computed: true,
Type: types.Int64Type,
},
}
}
}
}
}
}
problem_nested_list
does not appear in the plan summary printed by terraform plan
(this feels like a big clue), and if I drop it from the schema, everything works the way I expect.
What should I be doing differently?
Thanks!