You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should get an error that the JSON is invalid, similar to what happens in other cases of invalid JSON.
Actual Behavior
panic!
Steps to Reproduce
terraform init terraform plan --var-file=vars.tfvars.json
Additional Context
Arguably it's on the user to not provide invalid JSON, but, well, the crash output says This is always indicative of a bug within Terraform so here I am. I noticed this issue when absentmindedly trying to "comment out" part of the variable file 😛
References
The text was updated successfully, but these errors were encountered:
Hi @felixplajer! Sorry for this crash and thanks for reporting it.
I think you may have encountered the same bug that hashicorp/hcl#358 was aiming to fix. That fix has now been merged, and we have the new HCL version containing the fix in Terraform's master branch, so this issue ought to be resolved in the forthcoming Terraform v0.13 release.
I tried it on a build from the master branch to make sure, and indeed it didn't crash, though the errors it detected for your input were a bit "noisy" because the parser wasn't able to figure out what was going on enough to give a precise error in this case:
Error: Unclosed object
on terraform.tfvars.json line 1:
1: {
No closing brace was found for this JSON object.
Error: Root value must be object
on terraform.tfvars.json line 1:
1: {
The root value in a JSON-based configuration must be either a JSON object or a
JSON array of objects.
Error: Missing attribute seperator comma
on terraform.tfvars.json line 6:
6: / }
A comma must appear between each property definition in an object.
The third error does at least point to the problematic character though, which is better than the old behavior. HCL could potentially do a better job here by simply reporting that / is not a valid character in that context at all, but since that's relatively minor I'm going to consider this bug fixed -- it's no longer crashing -- and let the decision about whether to improve the JSON syntax error handling in HCL happen in the context of the HCL repository, rather than here.
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.
ghost
locked and limited conversation to collaborators
Jun 12, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Terraform Version
Terraform Configuration Files
main.tf:
Note, the same crash occurs if you have no configuration files at all. It's only related to the variable file.
vars.tfvars.json:
Several other characters also cause a panic:
\
,#
, etc.Debug Output
see crash log
Crash Output
crash log
Expected Behavior
Should get an error that the JSON is invalid, similar to what happens in other cases of invalid JSON.
Actual Behavior
panic!
Steps to Reproduce
terraform init
terraform plan --var-file=vars.tfvars.json
Additional Context
Arguably it's on the user to not provide invalid JSON, but, well, the crash output says
This is always indicative of a bug within Terraform
so here I am. I noticed this issue when absentmindedly trying to "comment out" part of the variable file 😛References
The text was updated successfully, but these errors were encountered: