diff --git a/command/format/diagnostic.go b/command/format/diagnostic.go index 2b1a7f826..2d9d9c8ae 100644 --- a/command/format/diagnostic.go +++ b/command/format/diagnostic.go @@ -213,6 +213,10 @@ func DiagnosticWarningsCompact(diags tfdiags.Diagnostics, color *colorstring.Col } func appendSourceSnippets(buf *bytes.Buffer, diag *viewsjson.Diagnostic, color *colorstring.Colorize) { + if diag.Address != "" { + fmt.Fprintf(buf, " (%s)\n", diag.Address) + } + if diag.Range == nil { return } diff --git a/command/views/json/diagnostic.go b/command/views/json/diagnostic.go index 3ea69db23..8ff595594 100644 --- a/command/views/json/diagnostic.go +++ b/command/views/json/diagnostic.go @@ -30,6 +30,7 @@ type Diagnostic struct { Severity string `json:"severity"` Summary string `json:"summary"` Detail string `json:"detail"` + Address string `json:"address,omitempty"` Range *DiagnosticRange `json:"range,omitempty"` Snippet *DiagnosticSnippet `json:"snippet,omitempty"` } @@ -124,6 +125,7 @@ func NewDiagnostic(diag tfdiags.Diagnostic, sources map[string][]byte) *Diagnost Severity: sev, Summary: desc.Summary, Detail: desc.Detail, + Address: desc.Address, } sourceRefs := diag.Source()