-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
core: Return an error when there's no remote state #7464
Conversation
When refreshing remote state, indicate when no state file was found with an ErrRemoteStateNotFound error. This prevents us from inadvertantly getting a nil state into a terraform.State where we assume there's always a root module.
Cool so this addresses the LGTM |
The error for a nil remote state was showing up in other places. While we could check for the error on all calls to Refresh(), this restores the previous behavior, while preventing possible nil values in the state. The effect here is the same, because rather than the RefreshState switching on cached != nil && durable == nil it will switch on durable.Serial < cached.Serial which sets the same value to RefreshResult().
Take a new approach to handling a nil remote state payload. Rather than define an error indicating a nil remote state (which would need to be moved to an internal package in order to be imported by all packages which could use it), we create an empty terraform.State with a Serial of -1 to ensure it's always superseded by any other state. This restores the previous behavior, while still preventing possible nil values in the state. The effect here is the same, because rather than the RefreshState switching on cached != nil && durable == nil it will switch on durable.Serial < cached.Serial which sets the same value to RefreshResult().
Take a new approach to handling a nil remote state payload. Rather than define an error indicating a nil remote state (which would need to be moved to an internal package in order to be imported by all packages which could use it), we create an empty terraform.State with a Serial of -1 to ensure it's always superseded by any other state. This restores the previous behavior, while still preventing possible nil values in the state. The effect here is the same, because rather than the RefreshState switching on cached != nil && durable == nil it will switch on durable.Serial < cached.Serial which sets the same value to RefreshResult().
Revert back to using a nil state. The external usage of the state shoudl always check the Empty() method.
Revert #7464 and allow an empty state
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. |
When refreshing remote state, indicate when no state file was found with
an ErrRemoteStateNotFound error. This prevents us from inadvertantly
getting a nil state into a terraform.State where we assume there's
always a root module.
Fixes #7455