terraform icon indicating copy to clipboard operation
terraform copied to clipboard

terraform: Error message for unknown error_message in variable validation

Open apparentlymart opened this issue 7 months ago • 0 comments

In cases where the condition is known but the error_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 https://github.com/hashicorp/terraform/issues/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.

╷
│ Error: Invalid error message
│ 
│   on child/validation-error-message-vars-child.tf line 11, in variable "test_input":
│   11:     error_message = var.error_message
│     ├────────────────
│     │ var.error_message is a string, known only after apply
│ 
│ Unsuitable value for error message: expression refers to values that won't be
│ known until the apply phase.
╵

apparentlymart avatar Jun 28 '24 22:06 apparentlymart