mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-06 06:37:58 -05:00
Now that we have a comprehensive JSON diagnostic structure, we can use it in the `validate -json` output instead of the inline version. Note that this changes the output of `validate -json` in two ways: 1. We fix some off-by-one errors caused by zero-width highlight ranges. This aligns the JSON diagnostic output with the text output seen by most Terraform users, so I consider this a bug fix. 2. We add the `snippet` field to the JSON diagnostics where available. This is purely additive and is permitted under our JSON format stability guarantees.
34 lines
892 B
JSON
34 lines
892 B
JSON
{
|
|
"valid": false,
|
|
"error_count": 1,
|
|
"warning_count": 0,
|
|
"diagnostics": [
|
|
{
|
|
"severity": "error",
|
|
"summary": "Reference to undeclared input variable",
|
|
"detail": "An input variable with the name \"description\" has not been declared. This variable can be declared with a variable \"description\" {} block.",
|
|
"range": {
|
|
"filename": "testdata/validate-invalid/missing_var/main.tf",
|
|
"start": {
|
|
"line": 6,
|
|
"column": 21,
|
|
"byte": 117
|
|
},
|
|
"end": {
|
|
"line": 6,
|
|
"column": 36,
|
|
"byte": 132
|
|
}
|
|
},
|
|
"snippet": {
|
|
"context": "resource \"test_instance\" \"foo\"",
|
|
"code": " description = var.description",
|
|
"start_line": 6,
|
|
"highlight_start_offset": 20,
|
|
"highlight_end_offset": 35,
|
|
"values": []
|
|
}
|
|
}
|
|
]
|
|
}
|