-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 on an invalid object definition (duplicate attribute) #33757
Comments
Hi @weakcamel! Sorry for this crash, and thanks for reporting it. Thanks in particular for including the trace logs; the early parts of that are particularly useful in situations like these because it allows us to quickly see exactly which versions of important dependencies like HCL are compiled into the Terraform release you are using, which allowed me to quickly narrow down that crash to some code that's trying to report an error with the default value of one of the attributes: I think what's happened here is that because you have a duplicate attribute name there's already a map entry for But the root problem is that it's missing a check near the top of the loop to see if that name was already declared: https://github.com/hashicorp/hcl/blob/e54a1960efd6cdfe35ecb8cc098bed33cd6001a8/ext/typeexpr/get_type.go#L181 I think it should be checking to make sure there isn't already an entry of the same name in This is actually a HCL bug rather than a Terraform bug, but since HCL is mostly maintained by the Terraform team I think we can keep this tracked here for now until someone is ready to work on a fix, at which point we can decide whether it's worth opening an issue in the HCL repository too or if this is straightforward enough to go straight to a PR -- I suspect it is. |
I've put together hashicorp/hcl#624 to address this. |
@apparentlymart @liamcervante |
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
Code (config) is obviously invalid and happened due to my copy-paste error.
I would expect some kind of syntax error though, not a fatal crash.
Actual Behavior
Crash.
Steps to Reproduce
terraform init
Additional Context
No response
References
No response
The text was updated successfully, but these errors were encountered: