Skip to content

Conversation

wata727
Copy link
Contributor

@wata727 wata727 commented Mar 13, 2025

Fixes #737
Follow up of #738

When the DiagnosticTextWriter writes out a diagnostic, if the diagnostic has an Expression and EvalContext, it will also write out the evaluation context in which the diagnostic occurred.

The cty.Value of the variable relevant to the expression will be rendered as a string by valueStr, but calls to AsString or LengthInt here will panic on marked values.

It is not clear how HCL should represent such marks, so we skip the marked values from the additional context as a general-purpose diagnostic writer.

Fixes hashicorp#737
Follow up of hashicorp#738

When the `DiagnosticTextWriter` writes out a diagnostic,
if the diagnostic has an Expression and EvalContext,
it will also write out the evaluation context
in which the diagnostic occurred.

The `cty.Value` of the variable relevant to the expression
will be rendered as a string by `valueStr`, but calls to
`AsString` or `LengthInt` here will panic on marked values.

It is not clear how HCL should represent such marks,
so we skip the marked values from the additional context
as a general-purpose diagnostic writer.
@crw
Copy link
Contributor

crw commented Mar 13, 2025

Thanks! Will make sure the team sees this.

@crw crw added the bug label Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DiagnosticTextWriter panics when writing a marked value

2 participants