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

configs: check for errors after LoadHCLFile #21825

Merged
merged 2 commits into from
Jun 21, 2019

Conversation

mildwonkey
Copy link
Contributor

The configs package was not checking the diagnostics for errors after loading files as HCL, which lead to panics in init and validate when terraform encountered invalid HCL.

The following config would produce an error out of terraform fmt, which explicitly validates the syntax first, but cause a panic in init or validate:

provider "aws" {
  region = var.aws_region
  version =
}

I think a follow-up HCL issue to improve the output in this instance is warranted:

$ terraform validate

Error: Invalid expression

  on main.tf line 3, in provider "aws":
   3:
   4:

Expected the start of an expression, but found an invalid expression token.

Fixes #21518

@mildwonkey mildwonkey requested a review from a team June 20, 2019 15:58
@mildwonkey
Copy link
Contributor Author

solution v2! Gracefully handle unexpected cty.DynamicVals in the version attribute.

@mildwonkey mildwonkey force-pushed the mildwonkey/b-provider-config-crash branch from ec862b3 to 3596664 Compare June 21, 2019 12:58
@mildwonkey mildwonkey requested a review from a team June 21, 2019 15:26
@mildwonkey
Copy link
Contributor Author

I did spend some time playing with go-fuzz, and I'll save that work in a branch for now but I have yet to coerce any new panics out of it.

@mildwonkey mildwonkey merged commit 2a45711 into master Jun 21, 2019
@mildwonkey mildwonkey deleted the mildwonkey/b-provider-config-crash branch June 21, 2019 18:30
@ghost
Copy link

ghost commented Jul 25, 2019

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 ghost locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Key with missing value in provider block causes Panic
3 participants