terraform: Error message for unknown error_message in variable validation #35400
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.
In cases where the
condition
is known but theerror_message
is not, we were previously returning the generic error about the error message not being evaluable.This is an interim change to give better feedback for the unfortunate situation described in #35397, so we can give authors better guidance in the meantime while we're designing a better solution.
In the long run we'll want to do something better here to minimize the chances of this situation arising -- reporting an error that we don't know how to describe is a poor user experience. But for now this at least acknowledges that an unknown value is the problem, and annotates the error message with the "caused by unknown" marking so that the UI will specify which of the contributing values was unknown.
(In this particular case the message is not fully accurate:
var.error_message
would be known during the plan phase, but isn't yet known during the validation phase. However, I've written it this way in anticipation of a future solution to #35397 that would avoid this error message being returned for anything that is unknown during the validate phase but yet would be known during the planning phase.)