Closed independentid closed 2 years ago
Further clarification. The problem does not occur if the underlying object is referential.
This works:
type HexaPolicyType struct {
Id types.String `tfsdk:"id"`
Meta MetaType `tfsdk:"meta"`
Subject SubjectType `tfsdk:"subject"`
Actions []ActionType `tfsdk:"actions"`
Object *ObjectType `tfsdk:"object"`
Scopes []ScopeType `tfsdk:"scopes"`
Condition *ConditionType `tfsdk:"condition"`
}
This will fail (when an attribute (e.g. "object") is optional:
type HexaPolicyType struct {
Id types.String `tfsdk:"id"`
Meta MetaType `tfsdk:"meta"`
Subject SubjectType `tfsdk:"subject"`
Actions []ActionType `tfsdk:"actions"`
Object ObjectType `tfsdk:"object"`
Scopes []ScopeType `tfsdk:"scopes"`
Condition ConditionType `tfsdk:"condition"`
}
I suppose this makes sense, but would be nice to have a better error. :)
Hello @independentid,
Thanks for filing the issue! This looks like an error from the terraform-plugin-framework, not the Terraform cli. This repo is only monitored by some of the core developers, so it would be helpful if you could file the issue in the terraform-plugin-framework repo here
Thanks!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Terraform Version
Terraform v1.2.2 on darwin_amd64
Terraform Configuration Files
This was a test configuration. If the "meta = {...}" lines are omitted the provider will throw unhandled null value error below.
Debug Output
Expected Behavior
The documentation indicates that if the parent object is optional then the whole thing may be omitted regardless of whether a child attribute is required. If the parent attribute is provided than optionality is enforced.
In this test, all attributes including the parent and child attributes are optional (Optional: true). Therefore missing optional objects should be accepted (e.g. no "meta={}".
Actual Behavior
Test fails when "meta ..." is omitted even though it is optional.
Steps to Reproduce
Create an attribute with type tfsdk.ListNestedAttributes and then a sub-attribute of type tfsdk.SingleNestedAttributes. Make both the parent and sub-attributes all Optional: true and the error will occur.
Additional Context
Just a simple test of the plugin framework template.
References
Have not found any so far.