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 - panic: can't use ElementIterator on null value #23507

Closed
im-lcoupe opened this issue Nov 26, 2019 · 5 comments
Closed

Terraform crash - panic: can't use ElementIterator on null value #23507

im-lcoupe opened this issue Nov 26, 2019 · 5 comments
Labels
bug crash v0.12 Issues (primarily bugs) reported against v0.12 releases

Comments

@im-lcoupe
Copy link

Hi,

I have recently experienced this issue in 3 separate workspaces - unfortunately the error doesn't give too much detail as to a possible cause (if the actual error lies within the code) - failing that, is this a genuine Terraform bug?

I first experienced this with a workspace running 0.12.13 - the code had already been applied and built - I then made a simple change, it reports what it intends to do but then drops into this panic and throws a number of errors. I initially just deleted the workspace from Terraform Enterprise and rebuilt it as it wasn't production. I have since used the upgrade tool to upgrade this particular workspace to 0.12.16.

I then figured it may be a bug in earlier versions so I proceeded to upgrade another workspace that had not yet thrown the error - I upgraded the code to 0.12.16 and it planned first, however, it soon threw the same error......

So now I am starting to think Terraform may be masking the actual error as these workspaces share a common codebase in the majority. However, without some more verbosity to the error, it's proving difficult to track down....thats assuming it is an error in the code and not a bug. A recent code change across all 3 workspaces led me to believe it may be this particular module, however, I have commented this out and it still throws the panic. Furthermore it seems to plan and then panic.

I can provide tf files - I just wanted to first clarify whether this is a bug or perhaps masking an error in my configuration.

Terraform Version

seen in 0.12.13 and now in 0.12.16

Crash Output

[0m�[1mPlan:�[0m 0 to add, 3 to change, 5 to destroy.�[0m
Failed running command "cd /terraform; envdir /env terraform show -json /terraform/terraform.tfplan" (exit 2)
Output: 

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

SECURITY WARNING: the "crash.log" file that was created may contain 
sensitive information that must be redacted before it is safe to share 
on the issue tracker.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
panic: can't use ElementIterator on null value

goroutine 1 [running]:
github.com/zclconf/go-cty/cty.Value.ElementIterator(0x230d360, 0xc000bd10a0, 0x0, 0x0, 0x1cdeea0, 0x1)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/[email protected]/cty/value_ops.go:922 +0xd5
github.com/hashicorp/terraform/command/jsonstate.marshalAttributeValues(0x230d360, 0xc000bd10a0, 0x0, 0x0, 0xc000ef0a00, 0x0)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/command/jsonstate/state.go:109 +0xc4
github.com/hashicorp/terraform/command/jsonstate.marshalResources(0xc000d07c80, 0xc000237460, 0x1, 0xc000dbb400, 0x14, 0x0, 0x0)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/command/jsonstate/state.go:325 +0x254
github.com/hashicorp/terraform/command/jsonstate.marshalModules(0xc00000ec20, 0xc000237460, 0xc0001ba600, 0x1d, 0x20, 0xc00070d528, 0x10, 0x20, 0x413d77, 0xc000523778, ...)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/command/jsonstate/state.go:227 +0x199
github.com/hashicorp/terraform/command/jsonstate.marshalRootModule(0xc00000ec20, 0xc000237460, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/command/jsonstate/state.go:210 +0x3c5
github.com/hashicorp/terraform/command/jsonstate.(*state).marshalStateValues(0xc000894600, 0xc00000ec20, 0xc000237460, 0x0, 0x1)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/command/jsonstate/state.go:159 +0x139
github.com/hashicorp/terraform/command/jsonstate.Marshal(0xc001489980, 0xc000237460, 0x0, 0x0, 0x0, 0x2e, 0x4a5a)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/command/jsonstate/state.go:139 +0x9e
github.com/hashicorp/terraform/command/jsonplan.Marshal(0xc00074d110, 0xc00029ed20, 0xc001489980, 0xc000237460, 0x0, 0x0, 0x0, 0x0, 0x0)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/command/jsonplan/plan.go:123 +0x75d
github.com/hashicorp/terraform/command.(*ShowCommand).Run(0xc000325520, 0xc0000b2020, 0x2, 0x2, 0xc00004f620)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/command/show.go:147 +0x929
github.com/mitchellh/cli.(*CLI).Run(0xc0000f8640, 0xc0000f8640, 0xc00051fd90, 0x1)
	/opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/mitchellh/[email protected]/cli.go:255 +0x1f1
main.wrappedMain(0x0)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/main.go:238 +0xc34
main.realMain(0x0)
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/main.go:102 +0xb4
main.main()
	/opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/main.go:38 +0x3b

Expected Behavior

The plan should finish and allow me to apply

Actual Behavior

The plan runs and then Terraform crashes. 
@ghost ghost added bug crash labels Nov 26, 2019
@pkolyvas pkolyvas added the v0.12 Issues (primarily bugs) reported against v0.12 releases label Nov 26, 2019
@danieldreier
Copy link
Contributor

@im-lcoupe this looks very similar to the issues resolved by #23492, which released in v0.12.17, which we're expecting to ship on Monday.

I think we should wait until 0.12.17 is released, and then I would appreciate it if you upgrade and then verify that this issue is resolved for you. Please let us know either way. If it's not fixed, we'll work on a reproduction case.

@im-lcoupe
Copy link
Author

@danieldreier thank you for getting back to me - much appreciated.

Sure - I will upgrade the workspace on Monday and report back here - hopefully it fixes the issue, as I'm nervous to run plans against our other workspaces and face the same issue...which may lead to a halt in development.

@danieldreier
Copy link
Contributor

@im-lcoupe I am fairly confident that this was resolved in the 0.12.17 release, so I'm going to go ahead and close this issue. Please do re-open it if you're still seeing the problem and I'm happy to work on a reproduction case together.

@recurrence
Copy link

To close the loop on this. I hit this as well and can confirm that upgrading from 0.12.16 to latest (19) fixed it.

@ghost
Copy link

ghost commented Jan 23, 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 Jan 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug crash v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

No branches or pull requests

4 participants