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 crash - reporting as instructed by the crash #5338

Closed
ellucianBret opened this issue Feb 26, 2016 · 9 comments · Fixed by #9698
Closed

Terraform crash - reporting as instructed by the crash #5338

ellucianBret opened this issue Feb 26, 2016 · 9 comments · Fixed by #9698
Assignees

Comments

@ellucianBret
Copy link

The console output seems to indicate that it crashed on a syntax error while parsing "${var.apply_immediately}"

Attached is the console output and the crash log

crash.log.txt
console.txt

@jen20
Copy link
Contributor

jen20 commented Mar 3, 2016

Relevant log section:

panic: Error reading level config: strconv.ParseBool: parsing "${apply_immediately}": invalid syntax
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws: 
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws: goroutine 134 [running]:
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.(*ResourceData).get(0xc820479f80, 0xc8201c6820, 0x1, 0x1, 0xc8201c6802, 0x0, 0x0, 0x0, 0x0, 0x1490000, ...)
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws:     /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/resource_data.go:385 +0x20a
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.(*ResourceData).getChange(0xc820479f80, 0x12be470, 0x11, 0x1201, 0x0, 0x0, 0x0, 0x0, 0xc820540000, 0x0, ...)
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws:     /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/resource_data.go:356 +0x235
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.(*ResourceData).diffChange(0xc820479f80, 0x12be470, 0x11, 0x0, 0x0, 0x0, 0x0, 0x0)
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws:     /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/resource_data.go:333 +0x78
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.schemaMap.diffString(0xc8205615c0, 0x12be470, 0x11, 0xc8201a95f0, 0xc8203b2e70, 0xc820479f80, 0x0, 0x0, 0x0)
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws:     /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/schema.go:919 +0xa5
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.schemaMap.diff(0xc8205615c0, 0x12be470, 0x11, 0xc8201a95f0, 0xc8203b2e70, 0xc820479f80, 0x0, 0x0, 0x0)
2016/02/26 05:32:59 [DEBUG] terraform-provider-aws:     /opt/gopath/src/github.com/hashicorp/terraform/helper/schema/schema.go:566 +0xaf

@ellucianBret
Copy link
Author

the crash was triggered by some invalid syntax, but it was a crash!

@iverberk
Copy link

I experienced a similar crash when I inadvertently assigned a number to the self parameter in the aws_security_group resource:

2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: panic: Error reading level config: strconv.ParseBool: parsing "8090": invalid syntax
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: goroutine 265 [running]:
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: panic(0xd95b00, 0xc820243970)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.(*ResourceData).get(0xc820430060, 0xc820548030, 0x1, 0x1, 0xc820548002, 0x0, 0x0, 0x0, 0x0, 0xc820510000, ...)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /private/tmp/terraform20160322-40204-nd0o52/terraform-0.6.14/src/github.com/hashicorp/terraform/helper/schema/resource_data.go:394 +0x20a
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.(*ResourceData).getChange(0xc820430060, 0x109b0f0, 0x7, 0x1201, 0x0, 0x0, 0x0, 0x0, 0x13c0000, 0x0, ...)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /private/tmp/terraform20160322-40204-nd0o52/terraform-0.6.14/src/github.com/hashicorp/terraform/helper/schema/resource_data.go:365 +0x235
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.(*ResourceData).diffChange(0xc820430060, 0x109b0f0, 0x7, 0x0, 0x0, 0x0, 0x0, 0xc820191168)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /private/tmp/terraform20160322-40204-nd0o52/terraform-0.6.14/src/github.com/hashicorp/terraform/helper/schema/resource_data.go:342 +0x78
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.schemaMap.diffSet(0xc820221b90, 0x109b0f0, 0x7, 0xc82055d6c0, 0xc820548010, 0xc820430060, 0x0, 0x0, 0x0)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /private/tmp/terraform20160322-40204-nd0o52/terraform-0.6.14/src/github.com/hashicorp/terraform/helper/schema/schema.go:808 +0x7c
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.schemaMap.diff(0xc820221b90, 0x109b0f0, 0x7, 0xc82055d6c0, 0xc820548010, 0xc820430060, 0x8fba00, 0x0, 0x0)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /private/tmp/terraform20160322-40204-nd0o52/terraform-0.6.14/src/github.com/hashicorp/terraform/helper/schema/schema.go:582 +0x32e
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.schemaMap.Diff(0xc820221b90, 0xc820198090, 0xc820198570, 0xc8201c8950, 0x0, 0x0)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /private/tmp/terraform20160322-40204-nd0o52/terraform-0.6.14/src/github.com/hashicorp/terraform/helper/schema/schema.go:302 +0x1ff
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.(*Resource).Diff(0xc82033ecc0, 0xc820198090, 0xc820198570, 0x12, 0x0, 0x0)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /private/tmp/terraform20160322-40204-nd0o52/terraform-0.6.14/src/github.com/hashicorp/terraform/helper/schema/resource.go:163 +0x44
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/helper/schema.(*Provider).Diff(0xc8202741e0, 0xc8202e0000, 0xc820198090, 0xc820198570, 0xc8204c5801, 0x0, 0x0)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /private/tmp/terraform20160322-40204-nd0o52/terraform-0.6.14/src/github.com/hashicorp/terraform/helper/schema/provider.go:175 +0x1c5
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: github.com/hashicorp/terraform/rpc.(*ResourceProviderServer).Diff(0xc8203275c0, 0xc8202440a0, 0xc820543730, 0x0, 0x0)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /private/tmp/terraform20160322-40204-nd0o52/terraform-0.6.14/src/github.com/hashicorp/terraform/rpc/resource_provider.go:334 +0x76
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: reflect.Value.call(0xd0ed80, 0xfe7bb8, 0x13, 0x10955f8, 0x4, 0xc8205a9ed8, 0x3, 0x3, 0x0, 0x0, ...)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /usr/local/Cellar/go/1.6/libexec/src/reflect/value.go:435 +0x120d
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: reflect.Value.Call(0xd0ed80, 0xfe7bb8, 0x13, 0xc8205a9ed8, 0x3, 0x3, 0x0, 0x0, 0x0)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /usr/local/Cellar/go/1.6/libexec/src/reflect/value.go:303 +0xb1
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: net/rpc.(*service).call(0xc82033fa80, 0xc82033f8c0, 0xc820349620, 0xc82042db80, 0xc8203275e0, 0xab9f00, 0xc8202440a0, 0x16, 0xab9f60, 0xc820543730, ...)
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /usr/local/Cellar/go/1.6/libexec/src/net/rpc/server.go:383 +0x1c2
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws: created by net/rpc.(*Server).ServeCodec
2016/03/31 11:18:35 [DEBUG] terraform-provider-aws:     /usr/local/Cellar/go/1.6/libexec/src/net/rpc/server.go:477 +0x49d 

@mitchellh
Copy link
Contributor

Does anyone have a config that can reproduce this? I have a hunch this is fixed on master since I can't repro it but w/o a known case where it was failing before I can't be 100% sure.

@ApsOps
Copy link

ApsOps commented Sep 8, 2016

@mitchellh Hi. I just tried with v0.7.3 and it still crashes. Please refer #7025 for config to test plus more details.

@sl1pm4t
Copy link
Contributor

sl1pm4t commented Oct 11, 2016

@mitchellh, @jen20 - looks to me like the the problem is Terraform doesn't attempt to interpolate bool attribute values.
Hence the panic when terraform tries to strconv.ParseBool the un-interpolated string.

This is demonstrated by the following config:

variable "bool_lookup" {
  type = "map"
  default = {
    "0" = false
    "1" = true
  }
}

data "template_cloudinit_config" "config" {
  count = 2
  // the following will crash terraform
  base64_encode          = "${ lookup(var.bool_lookup, count.index, true) }"

  part {
    content_type = "text/x-shellscript"
    content      = "ffbaz"
  }
}

console output
crash.log

Also, in the original reported problem, the variable reference was missing var. prefix so it should have failed when Terraform attempted to interpolate the value.

@sl1pm4t
Copy link
Contributor

sl1pm4t commented Oct 12, 2016

I take it back.... the above config works with the following change:

# BEFORE
base64_encode          = "${ lookup(var.bool_lookup, count.index, true) }"
# AFTER
base64_encode          = "${ lookup(var.bool_lookup, count.index, "true") }"

mitchellh added a commit that referenced this issue Oct 28, 2016
Fixes #5338 (and I'm sure many others)

There is no use case for "simple" variables in Terraform at all so
anytime one is found it should be an error.

There is a _huge_ backwards incompatibility here that was not supposed
to be by design but I'm sure a lot of people are relying on: in the
`template_file` datasource, this bug allowed you to not escape your
interpolations and have the work. For example:

```
data "template_file" "foo" {
  template = "${a}"
  vars { a = 12 }
}
```

The above would work, but it shouldn't. The template should have to be
`"$${a}"` (to escape the interpolation).

Because of this BC, I recommend holding this until Terraform 0.8.0 and
documenting it carefully. As part of this PR, I've added some special
error message notes.
@mitchellh
Copy link
Contributor

The referenced PR contains a fix for this issue, experienced by @sl1pm4t.

This is actually part of a larger bug (that includes necessary BC breaking changes) that we'll be releasing fixes to as part of Terraform 0.8.0, as noted in the PR itself.

@mitchellh mitchellh self-assigned this Oct 28, 2016
gusmat pushed a commit to gusmat/terraform that referenced this issue Dec 6, 2016
Fixes hashicorp#5338 (and I'm sure many others)

There is no use case for "simple" variables in Terraform at all so
anytime one is found it should be an error.

There is a _huge_ backwards incompatibility here that was not supposed
to be by design but I'm sure a lot of people are relying on: in the
`template_file` datasource, this bug allowed you to not escape your
interpolations and have the work. For example:

```
data "template_file" "foo" {
  template = "${a}"
  vars { a = 12 }
}
```

The above would work, but it shouldn't. The template should have to be
`"$${a}"` (to escape the interpolation).

Because of this BC, I recommend holding this until Terraform 0.8.0 and
documenting it carefully. As part of this PR, I've added some special
error message notes.
@ghost
Copy link

ghost commented Apr 20, 2020

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 Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants