Undefined fields in SingleNestedAttribute do not receive an error when they are defined

Is there a way when developing provider to avoid user’s from configure non-defined fields in SingleNestedAttribute?

e.g. -

attribute = {
 undefined_field = "value"
}

I want the user to get an error when running plan.

I’ve noticed it too. This issue seems related.

It’s super irritating when filling in optional attribute thing_value without remembering the correct attribute string is thing_val and nothing indicates you’ve screwed up the syntax.

Yeah as Brian mentions in that issue linked from @hQnVyLRx , currently providers don’t receive those non-schema fields from the plugin protocol RPCs, as HCL ends up filtering it out on the Terraform core side.

I’ll link another relevant issue in Terraform core about this exact topic that contains more info, as well as some comparisons of behavior between using a block vs. nested attribute. I’d subscribe there for more updates :+1:

Hey @austin.valle,

Your second link (“another relevant issue”) goes to the same place as the first.

Did you mean to send it somewhere else? I’m interested in reading another relevant issue.

Thanks!

1 Like

Apologies! This is the issue in terraform core: Reject or warn about additional attributes during object type conversion · Issue #33570 · hashicorp/terraform · GitHub

(I fixed the original links as well)

1 Like