opentofu/internal/command/views
Martin Atkins 70bc432f85 command/views/json: Never generate invalid diagnostic snippet offsets
Because our snippet generator is trying to select whole lines to include
in the snippet, it has some edge cases for odd situations where the
relevant source range starts or ends directly at a newline, which were
previously causing this logic to return out-of-bounds offsets into the
code snippet string.

Although arguably it'd be better for the original diagnostics to report
more reasonable source ranges, it's better for us to report a
slightly-inaccurate snippet than to crash altogether, and so we'll extend
our existing range checks to check both bounds of the string and thus
avoid downstreams having to deal with out-of-bounds indices.

For completeness here I also added some similar logic to the
human-oriented diagnostic formatter, which consumes the result of the
JSON diagnostic builder. That's not really needed with the additional
checks in the JSON diagnostic builder, but it's nice to reinforce that
this code can't panic (in this way, at least) even if its input isn't
valid.
2021-06-28 13:42:28 -07:00
..
json command/views/json: Never generate invalid diagnostic snippet offsets 2021-06-28 13:42:28 -07:00
add_test.go remove IsMarked and ContainsMarked calls 2021-06-25 14:17:06 -04:00
add.go remove IsMarked and ContainsMarked calls 2021-06-25 14:17:06 -04:00
apply_test.go update to use typed sensitive marks 2021-06-25 12:49:07 -04:00
apply.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
hook_count_test.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
hook_count.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
hook_json_test.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
hook_json.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
hook_ui_test.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
hook_ui.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
json_view_test.go Move plans/ to internal/plans/ 2021-05-17 14:09:07 -07:00
json_view.go command/views: Remove unused drift summary message 2021-05-25 15:54:57 -04:00
operation_test.go no drift with only deposed changes 2021-05-24 17:17:52 -04:00
operation.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
output_test.go Move states/ to internal/states/ 2021-05-17 14:09:07 -07:00
output.go Move states/ to internal/states/ 2021-05-17 14:09:07 -07:00
plan_test.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
plan.go typo 2021-05-25 08:32:44 -04:00
refresh_test.go update to use typed sensitive marks 2021-06-25 12:49:07 -04:00
refresh.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
show.go Move terraform/ to internal/terraform/ 2021-05-17 14:09:07 -07:00
state_locker.go Move command/ to internal/command/ 2021-05-17 14:09:07 -07:00
test_test.go Move command/ to internal/command/ 2021-05-17 14:09:07 -07:00
test.go Move command/ to internal/command/ 2021-05-17 14:09:07 -07:00
validate_test.go Move command/ to internal/command/ 2021-05-17 14:09:07 -07:00
validate.go Move command/ to internal/command/ 2021-05-17 14:09:07 -07:00
view.go Move command/ to internal/command/ 2021-05-17 14:09:07 -07:00