-
Notifications
You must be signed in to change notification settings - Fork 10.2k
backend/http: Refresh state earlier (align with other backends) #38033
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SarahFrench
reviewed
Jan 12, 2026
a4b279b to
d1cdd0f
Compare
This aligns the http backend with the implementation of StateMgr in other remote backends, which in turn enables easier testing of higher level logic that relies on certain backend behaviours.
d1cdd0f to
964de38
Compare
SarahFrench
reviewed
Jan 14, 2026
964de38 to
0d0cfb5
Compare
SarahFrench
approved these changes
Jan 14, 2026
Member
SarahFrench
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM!
This was referenced Jan 14, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
1.14-backport
If you add this label to a PR before merging, backport-assistant will open a new PR once merged
backend/http
skip-changelog-check
tests
Issues with Terraform's own tests (not "terraform test" or other testing functionality)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates the
httpbackend's behaviour such that it refreshes state prior to returning theStateMgr. In practice this should not have any impact on the end user, perhaps just that errors will be raised a little bit earlier.This change however enables us to now use that backend to test edge cases and prevent bugs such as #38027
Prior to this patch, the
httpbackend is not actually impacted by the crash reported in #38027Some backends (azure, gcs, kubernetes) are assumed to be impacted as they implement the exact same behaviour I'm trying to mimic here:
terraform/internal/backend/remote-state/azure/backend_state.go
Lines 107 to 110 in 193867f
terraform/internal/backend/remote-state/gcs/backend_state.go
Lines 108 to 111 in 193867f
terraform/internal/backend/remote-state/kubernetes/backend_state.go
Lines 94 to 97 in 193867f
Other backends implement the same logic conditionally (only refresh once a previously not-existing state was auto-created) but the bug likely impacts them in a similar way anyway:
terraform/internal/backend/remote-state/consul/backend_state.go
Lines 120 to 124 in 193867f
terraform/internal/backend/remote-state/cos/backend_state.go
Lines 126 to 130 in 193867f
terraform/internal/backend/remote-state/oci/backend_state.go
Lines 88 to 91 in 193867f
terraform/internal/backend/remote-state/oss/backend_state.go
Lines 162 to 166 in 193867f
terraform/internal/backend/remote-state/s3/backend_state.go
Lines 231 to 234 in 193867f
I'm open to breaking away the last commit and reviewing it alongside #38028 - we cannot really merge this PR on its own without #38028 anyway but having it crash like this in isolation hopefully demonstrates the value.