Skip to content

Skip marked values when writing diagnostics #739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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