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
Member

mildwonkey commented Jun 20, 2019

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 hashicorp/terraform-core Jun 20, 2019
@mildwonkey

This comment has been minimized.

Copy link
Member Author

mildwonkey commented Jun 20, 2019

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 Jun 21, 2019
@mildwonkey mildwonkey requested a review from hashicorp/terraform-core Jun 21, 2019
@mildwonkey

This comment has been minimized.

Copy link
Member Author

mildwonkey commented Jun 21, 2019

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
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details
@mildwonkey mildwonkey deleted the mildwonkey/b-provider-config-crash branch Jun 21, 2019
@hashibot

This comment has been minimized.

Copy link

hashibot bot 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.

@hashibot hashibot bot 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.
Projects
None yet
3 participants
You can’t perform that action at this time.