From c3fb92c1ce2000615a12556307f4a3f64f3a4c61 Mon Sep 17 00:00:00 2001 From: Daniel Banck Date: Mon, 6 Jan 2025 16:51:28 +0100 Subject: [PATCH] Fix `terraform console` crash for ephemeral values (#36267) We now check if a value has an ephemeral mark before trying to format it. The check prevents us from passing a marked value to go-cty's AsString function, which leads to a crash. --- internal/repl/format.go | 3 +++ internal/repl/format_test.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/internal/repl/format.go b/internal/repl/format.go index b64c2d5bc90b..ebadd18873f3 100644 --- a/internal/repl/format.go +++ b/internal/repl/format.go @@ -23,6 +23,9 @@ func FormatValue(v cty.Value, indent int) string { if v.HasMark(marks.Sensitive) { return "(sensitive value)" } + if v.HasMark(marks.Ephemeral) { + return "(ephemeral value)" + } if v.IsNull() { ty := v.Type() switch { diff --git a/internal/repl/format_test.go b/internal/repl/format_test.go index e4b86fa91fce..f55f58d7cd6a 100644 --- a/internal/repl/format_test.go +++ b/internal/repl/format_test.go @@ -177,6 +177,10 @@ EOT_`, cty.StringVal("a sensitive value").Mark(marks.Sensitive), "(sensitive value)", }, + { + cty.StringVal("an ephemeral value").Mark(marks.Ephemeral), + "(ephemeral value)", + }, } for _, test := range tests {