Struct embedding in attribute models

Hi!

I’m trying to compose several structs to describe my attribute schema:

type testDataSourceModel1 struct {
	ID types.String `tfsdk:"id"`
}
type testDataSourceModel2 struct {
	testDataSourceModel1
	Version types.String `tfsdk:"version"`
}

But Terraform cannot find tags in a parent struct:

data.teamcity_test.buildserver: Reading...
╷
│ Error: Value Conversion Error
│ 
│   with data.teamcity_test.buildserver,
│ An unexpected error was encountered trying to convert the Terraform value. This is always an error in the provider. Please report the
│ following to the provider developer:
│ 
│ expected tftypes.Object["id":tftypes.String, "version":tftypes.String], got tftypes.Object["version":tftypes.String]

Am I doing something wrong?
Here is the full sample: test.go · GitHub

That’s Framework 1.1.1 and Terraform 1.3.5

Hi @mkuzmin
Sorry that you are running into trouble here. Unfortunately, the Framework currently doesn’t support unmarshalling nested structs, so you would have to create a separate struct with duplicate fields from the parent struct.

There is an open issue regarding this that you can follow on Github: "Follow" Embedded Structs · Issue #242 · hashicorp/terraform-plugin-framework · GitHub. However, we already have other features queued up for the Framework, so we may not get to this issue in the near future.

Please let us know if you have any other questions/concerns,
Thanks