types.ListValueFrom produces the "" on conversion


I’m experiencing a bit of a problem with type conversion which hopefully someone could help clarifying

applicationResponseSpec.GithubAuthRoles JSON response produces object with the data


type GithubAuthRoleV1 struct {
	// Organization Name of the organization that owns the repository
	Organization GithubAuthRoleV1Organization `json:"organization"`

	// Repository Name of the github repository (case sensitive)
	Repository string `json:"repository"`

type GithubAuthRoleV1Organization string

and the data

   Organization: "ABC",
   Repository: "abc-123"

I have generated the code with a terraform framework generator which resulted in a Schema

"spec": schema.SingleNestedAttribute{
				Attributes: map[string]schema.Attribute{
					"github_auth_roles": schema.ListNestedAttribute{
						NestedObject: schema.NestedAttributeObject{
							Attributes: map[string]schema.Attribute{
								"organization": schema.StringAttribute{
									Required:            true,
									Description:         "Name of the organization that owns the repository",
									MarkdownDescription: "Name of the organization that owns the repository",
									Validators: []validator.String{
								"repository": schema.StringAttribute{
									Required:            true,
									Description:         "Name of the github repository (case sensitive)",
									MarkdownDescription: "Name of the github repository (case sensitive)",
									Validators: []validator.String{
							CustomType: GithubAuthRolesType{
								ObjectType: types.ObjectType{
									AttrTypes: GithubAuthRolesValue{}.AttributeTypes(ctx),
						Optional:            true,
						Description:         "List of github authentication roles to create",
						MarkdownDescription: "List of github authentication roles to create",

And a model

type GithubAuthRolesValue struct {
	Organization basetypes.StringValue `tfsdk:"organization"`
	Repository   basetypes.StringValue `tfsdk:"repository"`
	state        attr.ValueState

When I do a conversion like that

if applicationResponseSpec.GithubAuthRoles != nil {
		githubAuthRoles := make([]resource_mss_application.GithubAuthRolesValue, len(*applicationResponseSpec.GithubAuthRoles))
		for i, githubAuthRole := range *applicationResponseSpec.GithubAuthRoles {
			githubAuthRoles[i] = resource_mss_application.GithubAuthRolesValue{
				Organization: basetypes.NewStringValue(string(githubAuthRole.Organization)),
				Repository:   basetypes.NewStringValue(githubAuthRole.Repository),
		githubAuthRolesList, diagerr := types.ListValueFrom(ctx, data.Spec.GithubAuthRoles.ElementType(ctx), githubAuthRoles)
		data.Spec.GithubAuthRoles = githubAuthRolesList

It results in githubAuthRolesList being a list of 1 element (which is expected) with Organization and Repository set to “” instead of the actual values from the githubAuthRoles (which is not the desired outcome)

I’ve seen this working in various examples but can’t figure out what is wrong in this particular case.

New object of GithubAuthRolesValue have state=attr.ValueStateNull on the object level where it does have attr.ValueStateKnown for Organization and Repository


And because of that func (v GithubAuthRolesValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { assigns a no value to the object while converting

case attr.ValueStateNull:
		return tftypes.NewValue(objectType, nil), nil

Is this an feature of the generator or there is a better way of handling it?