-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
terraform plan
reports "planned for absence but config wants existence" when provider returns empty Set
#29576
Comments
Hi @ewbankkit! Thanks for reporting this. I'm still getting familiar with the new framework structures so possibly I'm misunderstanding the schema here, but it looks like this Replacing a null value with an empty set here is, from Terraform Core's perspective, the provider setting a default value for this argument, which we currently represent as the combination of Given that, you might be able to get the result you expected by marking this attribute also as |
This type is issue is something that has always been kind of a pain point for providers, but was masked by old protocol, because when we call What's happening here is that the resource is planning the change correctly, and honoring the configuration for So adding the The error message in this case I believe is one where I already tried to differentiate between a terraform bug and provider, but there was not enough information to do so, so stuck with |
Oh hmm yes, I was focusing on the final error message as included in the summary and didn't spot the context that the first weird error was from the In that case, I think this might be an example of what I was discussing in hashicorp/terraform-plugin-framework#70, where I think ideally the SDK would have a way for a provider developer to define what makes two values be considered equal and then use that both for planning and for refreshing, so we always stay consistent with the configuration. In the meantime though, indeed it seems like it would work either to do what I said above and thus make the empty set be a "default" for this argument, or to go the other way and have |
@apparentlymart This does seem to be an example of the behavior discussed in hashicorp/terraform-plugin-framework#70; The absence of an array (set or list) and an empty array are semantically equivalent at the cloud provider API level, at least for this particular attribute. @jbardin Yes,
Is this something that is likely to be happening provider-side? |
@ewbankkit, I'm going to come up with a repro to verify that and report back here. This is in an area where terraform blames the provider because it's most likely, but not always guaranteed. |
@ewbankkit: Confirmed the error is in Terraform. While it may be nice if the SDK provided some way to help providers normalize nil or empty values to prevent needing |
@jbardin |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform Version
Description
A protocol v6 resource type declares (using
terraform-plugin-framework
) an attributetags
of type:My configuration has no
tags
defined:On
terraform refresh
the underlying cloud provider API, and hence the provider, returns an empty array fortags
:and Terraform correctly shows a diff:
I change my configuration to try and suppress the diff and match the cloud provider API's result:
On
terraform refresh
I now get an error:I would expect Terraform to show no diff when both the configuration specifies an empty set and the provider/underlying cloud provider API returns an empty set.
The text was updated successfully, but these errors were encountered: