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
Panic thrown if Optional or Required not set to true #31211
Comments
Hi @independentid, Can you provide the error output from Terraform so we can see where the panic might originate? Thanks! |
I believe that it's correct to raise an error if an attribute doesn't have at least one of I suspect this flew under the radar so far because SDKv2 has its own validation checks for schema which can catch this before Terraform Core ever sees the schema, whereas the new framework exposes the Terraform Core schema primitives more directly and so is perhaps allowing this to pass through and expecting Terraform Core to check it. And it sounds like Terraform Core is checking it, but is not reporting it in a useful way, so I expect the fix will be to make it return a normal error diagnostic rather than to panic. |
Here is the relevant crash info...
|
I should comment as a newbie, I find it difficult to understand the difference between "Required" and "Optional" and how it impacts Terraform logic in particular. It seems like you just have to have something set to True (including "Computed". |
Thanks @independentid! This should be taken care of by #31184, which will show the framework diagnostics when something is missing in the schema. |
@independentid, I can certainly understand that these three flags can be quite confusing at first. I'm actually not sure where in the new framework docs they are documented. There are some notes about them in the SDKv2 documentation and this is one aspect which both SDKs largely have in common because it's reflecting some assumptions that come from the provider protocol itself, regardless of SDK. It looks like the Schemas section of the framework documentation covers similar information in a different structure. In case it's helpful, here's a table I sometimes use to summarize the different valid combinations and what they mean, although this does omit some details you can find in those docs I linked above:
The above are the only valid combinations for these three flags in the current protocol. If you run into other questions while you are working on this, you can ask about them in the Plugin SDK community forum, which covers both the old SDKv2 and the new framework. |
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
Terraform Configuration Files
Debug Output
Expected Behavior
Expecting the modified example data source to work. Modification included an object set with "Required: false" + markdown and type.
Actual Behavior
Panic attack thrown when example_data_source_test.go run
Steps to Reproduce
Additional Context
Nothing atypical. Took a while to find the issue.
Note: if you change the name of the provider, the provider_test.go must be updated or none of the tests will pass. This was not obvious in any documentation. Naming is hyper-sensitive to get plugin working. Additional diagnostics would be very helpful.
References
Unknown
The text was updated successfully, but these errors were encountered: