Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null computed ListAttribute when data source is read at apply time #1102

Open
marshallford opened this issue Feb 25, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@marshallford
Copy link

marshallford commented Feb 25, 2025

Hello 👋🏼 I apologize if this is a bug in my provider and not the plugin framework. This has been a head scratcher, so I thought I would open an issue. Thank you.

Module version

github.com/hashicorp/terraform-plugin-framework v1.13.0

Relevant provider source code

"artifact_queries": schema.MapNestedAttribute{
	Optional:            true,
	NestedObject: schema.NestedAttributeObject{
		Attributes: map[string]schema.Attribute{
			"jq_filter": schema.StringAttribute{
				Required:            true,
				Validators: []validator.String{
					stringIsJQFilter(),
				},
			},
			"results": schema.ListAttribute{
				Computed:            true,
				ElementType:         jsontypes.NormalizedType{},
			},
		},
	},
},

Terraform Configuration Files

See example here: marshallford/terraform-provider-ansible#79

Debug Output

https://gist.github.com/marshallford/38c159bd2ab5f7bb11119232bb717d8e

Expected Behavior

The data source attribute is considered "unknown" until it has been read. After the data source has been read the normal resource graph ordering should allow the data source attribute to be passed to other resources/outputs/etc.

Actual Behavior

The ListAttribute is not shown in the Terraform plan output (with (known after apply)) and Terraform evaluates the attribute as null before the data source has a chance to be read. It is almost as if there is a difference in behavior between a ListAttribute within a SingleNestedAttribute and a ListAttribute within a MapNestedAttribute.

Steps to Reproduce

  1. terraform init
  2. terraform plan

References

marshallford/terraform-provider-ansible#79

@marshallford marshallford added the bug Something isn't working label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant