Skip to content

Commit

Permalink
Fix terraform console crash for ephemeral values
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dbanck committed Jan 6, 2025
1 parent fa27595 commit 2df346b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/repl/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions internal/repl/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2df346b

Please sign in to comment.