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

terraform crashes if provider returns value that does not conform to expected schema #32092

Closed
sebhoss opened this issue Oct 27, 2022 · 3 comments
Labels
bug duplicate issue closed because another issue already tracks this problem

Comments

@sebhoss
Copy link

sebhoss commented Oct 27, 2022

Terraform Version

Terraform v1.4.0-dev
on linux_amd64

Terraform Configuration Files

# this is a simplified example
resource "example_resource" "testcase" {
  list_of_objects = [
    {
      name = "first"
      dynamic_attribute = 123 # NOTE: this is a dynamic type
    },
    {
      name = "second" # NOTE: dynamic_attribute is missing here
    },
  ]
}

Debug Output

https://gist.githubusercontent.com/sebhoss/ce219211c36bdb647893ddcb8ebfb8f0/raw/8714db3dc95b017aa7f08123c147829eb0d92357/logoutput.txt (crash is at the bottom)

Expected Behavior

I think Terraform Core should catch this issue sooner and tell the user that there is a problem with the provider rather than crash.

Actual Behavior

There is a crash in Terraform Core

Steps to Reproduce

  1. git clone https://github.com/metio/terraform-provider-k8s.git
  2. cd terraform-provider-k8s
  3. git switch issue-147
  4. make terratest TestAppsStatefulSetV1Resource

Note that the last step builds & installs the provider locally. I've only tested the install step (make install) on linux systems and it probably needs adjustments for mac/windows. Let me know if there is something I can do to help..

Additional Context

References

hashicorp/terraform-plugin-framework#147

@sebhoss
Copy link
Author

sebhoss commented Oct 27, 2022

Forgot to add the output of terraform providers schema -json: https://gist.github.com/sebhoss/886a7588ffff04aca04f9a88a3748503 contains the schema for the resource in the example. It was created by running:

  1. cd examples/resources/k8s_apps_stateful_set_v1
  2. terraform providers schema -json | jq '.provider_schemas."localhost/metio/k8s".resource_schemas.k8s_apps_stateful_set_v1' > schema.json

@jbardin
Copy link
Member

jbardin commented Oct 27, 2022

Thanks @sebhoss!

We are tracking the task to write more involved client-side validation in #30669.

Duplicate of #30669

@jbardin jbardin closed this as completed Oct 27, 2022
@crw crw added duplicate issue closed because another issue already tracks this problem and removed new new issue not yet triaged labels Nov 3, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2022

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.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug duplicate issue closed because another issue already tracks this problem
Projects
None yet
Development

No branches or pull requests

3 participants