I have a custom provider for some internal resources in our company. Currently, the provider has a resource that impls resource.ResourceWithConfigure. Everything works perfectly fine with this resource, Configure gets called with the expected ProviderData set up in the provider’s Configure method, which sets up the necessary resources to make its API calls.
I have been trying out creating a new List implementation for this resource, currently using plugin framework version 1.16.1 and the released terraform_1.14.0-rc2_darwin_arm64 build. As the resource already impls resource.ResourceWithConfigure, I set it up to also impl list.ListResource and list.ListResourceWithConfigure, leaving it to use the original and thoroughly tested Configure method on the resource struct, and wrote a new List method. I created a basic .tfquery.hcl file for it and tried to run it.
When I run a test list query, I find that the Configure method on the struct does get run, but only with the req.ProviderData == nil. If I run a regular read query with the same code, it gets called once with the data nil, and again with it populated. So it seems like the list code might be missing something.
I’ve never tried this API before, so it’s possible I’m doing something wrong, but it does seem like this might be an actual bug somewhere.
One thing to double check is whether in your Provider type Configure method that you’re also setting the response ListResourceData (provider package - github.com/hashicorp/terraform-plugin-framework/provider - Go Packages), similar to ResourceData. Without that, the data for list resources will not be set during their Configure method calls. Those fields are separated for each provider concept should there be a need to conditionally change the available provider data being passed to them (although admittedly, atypical use case).
Ah, thanks, that was it exactly! I updated the provider Configure to set ListResourceData as well, and it started working immediately.
I suppose a few minor documentation updates could make this clearer. First off, the section you linked in the Provider ConfigureResponse appears to be copy-pasted from ActionData with only the first line changed, while the others still refer to Action-based types. Second, it would be nice if the docs for ListResourceWithConfigure explicitly called out that even though the impl method is the same as for ResourceWithConfigure, when it is called for a List resource, it will get passed the data the Provider set in ListResourceData instead of ResourceData.
It would also be nice to call out more explicitly somewhere that the ListResource interfaces are intended to be impled on the same struct as the Resource, as it took me a while to figure that out. Also that you probably need to impl ResourceWithIdentity too in order to define the identity schema.