Address ephemeralasnull comments/TODOs (#3169)

Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
Christian Mesh
2025-08-22 09:59:24 -04:00
parent 19eed53765
commit 4ad9dfa716
4 changed files with 5 additions and 9 deletions

View File

@@ -54,7 +54,7 @@ func TestEphemeralErrors_variables(t *testing.T) {
t.Errorf("unexpected err: %s;\nstderr:\n%s\nstdout:\n%s", err, serr, sout)
}
sanitized := SanitizeStderr(serr)
if !strings.Contains(sanitized, `The error expression used to explain this condition refers to ephemeral values. OpenTofu will not display the resulting message. You can correct this by removing references to ephemeral values.`) {
if !strings.Contains(sanitized, `The error expression used to explain this condition refers to ephemeral values. OpenTofu will not display the resulting message. You can correct this by removing references to ephemeral values or by utilizing the builtin ephemeralasnull() function.`) {
t.Errorf("unexpected stderr: %s;\nstderr:\n%s\nstdout:\n%s", err, serr, sout)
t.Logf("sanitized serr: %s", sanitized)
}

View File

@@ -284,7 +284,7 @@ You can correct this by removing references to sensitive values, or by carefully
Summary: "Error message refers to ephemeral values",
Detail: `The error expression used to explain this condition refers to ephemeral values, so OpenTofu will not display the resulting message.
You can correct this by removing references to ephemeral values.`, // TODO ephemeral - update the message to include ephemeralasnull option too
You can correct this by removing references to ephemeral values or by utilizing the builtin ephemeralasnull() function.`,
Subject: expr.Range().Ptr(),
Expression: expr,
EvalContext: hclCtx,

View File

@@ -479,7 +479,7 @@ You can correct this by removing references to sensitive values, or by carefully
Summary: "Error message refers to ephemeral values",
Detail: `The error expression used to explain this condition refers to ephemeral values. OpenTofu will not display the resulting message.
You can correct this by removing references to ephemeral values.`, // TODO ephemeral - update the message to include ephemeralasnull option too
You can correct this by removing references to ephemeral values or by utilizing the builtin ephemeralasnull() function.`,
Subject: validation.ErrorMessage.Range().Ptr(),
Expression: validation.ErrorMessage,

View File

@@ -1656,9 +1656,7 @@ variable "bar" {
validation {
condition = length(var.bar) == 4
// error_message = "Bar must be 4 characters, not ${ephemeralasnull(length(var.bar))}."
// TODO ephemeral - enable the error_message above after ephemeralasnull is introduced
error_message = "Value for bar must be 4 characters"
error_message = "Bar must be 4 characters, not ${coalesce(ephemeralasnull(length(var.bar)), "(hidden ephemeral)")} characters."
}
}
`
@@ -1716,9 +1714,7 @@ variable "bar" {
given: cty.StringVal("bap"),
wantErr: []string{
"Invalid value for variable",
// "Bar must be 4 characters, not null.",
// TODO ephemeral - enable the line above after "ephemeralasnull" is introduced
"Value for bar must be 4 characters",
"Bar must be 4 characters, not (hidden ephemeral) characters.",
},
status: checks.StatusFail,
},