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 test: referencing variables at testing file level results in a crash #34529

Closed
liamcervante opened this issue Jan 16, 2024 · 1 comment · Fixed by #34531
Closed
Assignees
Labels
bug confirmed a Terraform Core team member has reproduced this issue v1.7 Issues (primarily bugs) reported against v1.7 releases

Comments

@liamcervante
Copy link
Member

Terraform Version

v1.7.0-rc2

Terraform Configuration Files

# main.tf

variable "input" {
    type = string
}

output "value" {
    value = var.input
} 
# main.tftest.hcl

variables {
  input = var.env_var_input
}

run "execute" {}

Debug Output

N/A

Expected Behavior

should not crash, and should be able to reference environment variable

Actual Behavior

terraform test
main.tftest.hcl... in progress

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

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.

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

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

runtime error: invalid memory address or nil pointer dereference
goroutine 11 [running]:
runtime/debug.Stack()
        /Users/runner/hostedtoolcache/go/1.21.5/x64/src/runtime/debug/stack.go:24 +0x64
runtime/debug.PrintStack()
        /Users/runner/hostedtoolcache/go/1.21.5/x64/src/runtime/debug/stack.go:16 +0x1c
github.com/hashicorp/terraform/internal/logging.PanicHandler()
        /Users/runner/work/terraform/terraform/internal/logging/panic.go:58 +0x164
panic({0x105df7600?, 0x107c13c30?})
        /Users/runner/hostedtoolcache/go/1.21.5/x64/src/runtime/panic.go:914 +0x218
github.com/hashicorp/terraform/internal/backend/local.(*TestFileRunner).GetVariables(0x14000a3def8, 0x1400017e9a0, 0x1400009d3b0, {0x0, 0x0, 0x102fc0560?})
        /Users/runner/work/terraform/terraform/internal/backend/local/test.go:1063 +0x530
github.com/hashicorp/terraform/internal/backend/local.(*TestFileRunner).run(0x14000a3def8, 0x1400009d3b0, 0x1400009d400, 0x1400091c370, 0x1400017e9a0)
        /Users/runner/work/terraform/terraform/internal/backend/local/test.go:405 +0x708
github.com/hashicorp/terraform/internal/backend/local.(*TestFileRunner).Test(0x14000a3def8, 0x1400009d400)
        /Users/runner/work/terraform/terraform/internal/backend/local/test.go:336 +0x48c
github.com/hashicorp/terraform/internal/backend/local.(*TestSuiteRunner).Test(0x140004c45a0)
        /Users/runner/work/terraform/terraform/internal/backend/local/test.go:140 +0x2bc
github.com/hashicorp/terraform/internal/command.(*TestCommand).Run.func1()
        /Users/runner/work/terraform/terraform/internal/command/test.go:230 +0x9c
created by github.com/hashicorp/terraform/internal/command.(*TestCommand).Run in goroutine 1
        /Users/runner/work/terraform/terraform/internal/command/test.go:224 +0xab4

Steps to Reproduce

terraform init
terraform test

Additional Context

No response

References

No response

@liamcervante liamcervante added bug new new issue not yet triaged labels Jan 16, 2024
@liamcervante liamcervante self-assigned this Jan 16, 2024
@liamcervante liamcervante added confirmed a Terraform Core team member has reproduced this issue and removed new new issue not yet triaged labels Jan 16, 2024
@apparentlymart apparentlymart added the v1.7 Issues (primarily bugs) reported against v1.7 releases label Jan 19, 2024
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug confirmed a Terraform Core team member has reproduced this issue v1.7 Issues (primarily bugs) reported against v1.7 releases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants