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
Inconsistent Optional w/ Default behavior #1185
Comments
Hi @tylerFowler 👋 Thank you for raising this and sorry you ran into this confusing contradiction in the Go documentation. This additional documentation was added as part of #912 along with a bunch of other schema documentation changes. I'm guessing I was optimistically trying to document what Terraform normally expects from providers in this case, but didn't explicitly verify that it was actually possible in this SDK. This SDK sets a special flag when communicating with Terraform that enables some demotes some Terraform data consistency errors to warning logs. Newer SDKs, such as terraform-plugin-framework, intentionally do not set this special flag so provider developers are always aware of schema definition or data handling logic issues. Rather than potentially removing the schema implementation validation logic for this: if v.Computed && v.Default != nil {
return fmt.Errorf("%s: Default must be nil if computed", k)
} And have other potential unexpected behaviors introduced for provider developers if they do try to set |
… Go documentation Reference: #1185 While the intention of the Go documentation matches Terraform's expectations, other parts of the SDK explicitly validate against the schema definition it was recommending. This documentation change is safer than trying to reconcile all the potential behavior changes should this particular validation be removed and a developer attempts to set `Computed`.
… Go documentation (#1188) Reference: #1185 While the intention of the Go documentation matches Terraform's expectations, other parts of the SDK explicitly validate against the schema definition it was recommending. This documentation change is safer than trying to reconcile all the potential behavior changes should this particular validation be removed and a developer attempts to set `Computed`.
This is totally fine, just wanted to ensure that the version of the logic is in fact the correct one. My changeset that led me to this was one in response to seeing messages in Terraform logs like "provider xxxx unexpectedly produced new value for attribute Y ..." |
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. |
SDK version
v2.24.1
Relevant provider source code
Debug Output
Expected Behavior
Per the SDK documentation:
Actual Behavior
This recommendation of supplying "Computed" when both "optional" and with a "default" seems to produce an error suggesting that "Computed" attributes must never have a default.
The text was updated successfully, but these errors were encountered: