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.
pull/36187/head
Daniel Banck 1 year ago committed by GitHub
parent 908828be8a
commit c3fb92c1ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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 {

@ -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 {

Loading…
Cancel
Save