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

panic: runtime error in stateVersions.Upload #791

Closed
LukasHeimann opened this issue Oct 12, 2023 · 4 comments · Fixed by #792
Closed

panic: runtime error in stateVersions.Upload #791

LukasHeimann opened this issue Oct 12, 2023 · 4 comments · Fixed by #792
Labels
bug Something isn't working

Comments

@LukasHeimann
Copy link

LukasHeimann commented Oct 12, 2023

go-tfe version

1.34.0

Embedded in Terraform 1.6.1

Description

When I ran terraform apply, terraform dumped with a stacktrace pointing to go-tfe:

Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x11e9936]

goroutine 1150 [running]:
github.com/hashicorp/go-tfe.(*stateVersions).Upload.func1()
	/home/runner/go/pkg/mod/github.com/hashicorp/[email protected]/state_version.go:294 +0xb6
golang.org/x/sync/errgroup.(*Group).Go.func1()
	/home/runner/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 39
	/home/runner/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:72 +0x96

(see https://github.com/golang/sync/blob/v0.3.0/errgroup/errgroup.go#L75 and https://github.com/hashicorp/go-tfe/blob/v1.34.0/state_version.go#L294)

While the log shows the issue in a situation with unchanged infrastructure, this also happens when changes were applied successfully. However, the updated state was not persisted, as I was able to validate with a subsequent terraform plan.

This may or may not be related to the remote backend I am using. In the past, it also sometimes had problems where fields were missing, causing problems with newer versions of go-tfe (via newer versions of terraform).

In any case, I'd have expected a good exception instead of a segfault, which also leaves the terraform state locked instead of failing more gracefully.

The problem happens both in a ci system (linux) as well as on a developer machine (windows 11).

Thank you very much for your support!

Testing plan

?

Expected Behavior

go-tfe should not crash

Actual Behavior

go-tfe crashed with a segfault

Additional Context

@LukasHeimann LukasHeimann added the bug Something isn't working label Oct 12, 2023
@LukasHeimann LukasHeimann changed the title panic: runtime error in stateVersions.upload panic: runtime error in stateVersions.Upload Oct 12, 2023
@brandonc
Copy link
Collaborator

Hey, thanks for this report. I definitely see an issue with attempting to upload a state version after it failed to be created (If Line 287 evaluates to false)

Are you running against Terraform Enterprise? I wonder if you could give me some some details about which version
that is.

@ToniA
Copy link

ToniA commented Oct 17, 2023

I think this is the same issue I have with JFrog Artifactory backend store. Terraform versions up to 1.5.7 work fine.

@brandonc
Copy link
Collaborator

This fix will be released in Terraform 1.6.2

@LukasHeimann
Copy link
Author

I assume it will still not work with Artifactory as a backend, because the error is explicitly triggered due to Artifactories "not implemented" error message having a different string value then (older) Terraform Enterprise messages, though -- it just will fail more gracefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants