hashicorp / hashicorp/terraform-plugin-framework
Undefined attribute in `tfsdk.SingleNestedAttributes` is not detected during terraform validate
- Dominant language
- Go
- Stars
- 384
- Forks
- 107
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
### Module version
```
v1.19.0
```
### Relevant provider source code
```go
"http": {
Description: "Configuration for the HTTP authentication scheme",
MarkdownDescription: "Configuration for the HTTP authentication scheme",
Optional: true,
Attributes: tfsdk.SingleNestedAttributes(
map[string]tfsdk.Attribute{
"type": {
Description: fmt.Sprintf("The type of the authentication scheme. Possible values are `%s`", client.HTTPAuthTypeBasic),
MarkdownDescription: fmt.Sprintf("The type of the authentication scheme. Possible values are `%s`", client.HTTPAuthTypeBasic),
Required: true,
Type: types.StringType,
Validators: []tfsdk.AttributeValidator{validator.StringInSlice(string(client.HTTPAuthTypeBasic))},
},
"username": {
Description: "The username",
MarkdownDescription: "The username",
Type: types.StringType,
Optional: true,
},
"password": {
Description: "The user password",
MarkdownDescription: "The user password",
Type: types.StringType,
Optional: true,
Sensitive: true,
},
},
),
},
```
### Terraform Configuration Files
```hcl
http = {
type = "Basic"
username = "magodo"
password = "***"
foo = "bar" # undefined
}
```
### Debug Output
### Expected Behavior
Running `terraform validate`, it should error out as there is an undefined attribute `foo` in the `http` object.
```
An argument named "foo" is not expected here.
```
### Actual Behavior
```
Success! The configuration is valid, but there were some validation warnings as shown above.
```
### References
This is an reopen of #304, which was closed before. I find it is a different issue here given this one is about plugin framework do not always raise an error for undefined attributes inside nested objects, instead of TF core doesn't raise validation error for non-configurable properties (e.g. computed only attribute).
Contributor guide
Research direction
Start by examining the tfsdk.SingleNestedAttributes handling and reproducing the provided nested configuration with terraform validate. Done means the undefined foo attribute in the http object produces an error instead of a successful validation result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, terraform
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100