core: Don't panic if EvalMaybeResourceDeposedObject has no DeposedKey #23718
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 is a "should never happen" case, but we have reports of it actually happening. In order to try to collect a bit more data about what's going on here, we're changing what was previously a hard panic into a normal error message that can include the address of the instance we were working on and the action we were trying to do to it at the time.
The hope is to narrow down what situations can trigger this in order to find a reliable reproduction case in order to debug further. This also means that for those who do encounter this problem in the meantime Terraform will have a chance to shut down cleanly and therefore be more likely to be able to recover on a subsequent plan/apply cycle.
Further investigation of this will follow once we see a report or two of this updated error message.
This closes #23709, and is aiming to contribute to eventually figuring out #22974 in a later change.
This also includes some tweaks to some tests that are not directly related to this change but that behaved in unfortunate ways when I faked an occurrence of this problem in order to test the error messages. Neither of those changes affects the outcome of the change I've made here, but both of these tests will now behave better when receiving an error other than the one they are expecting.