Repository navigation
fix: load YAML reports in diff --report - #1769
Merged
Merged
Conversation
report.Load only parsed JSON, so diffing two reports written with --format yaml failed with "invalid character 'i' in literal false". Input that does not parse as JSON and is not a JSON object is now read as YAML, which the YAML renderer writes with its file reports under "files". Input that is neither keeps the JSON error.
RaphaelFakhri
force-pushed
the
fix/diff-report-yaml
branch
from
October 21, 2026 12:19
cbe2d11 to
88f17ff
Compare
egibs
approved these changes
Oct 27, 2026
| if trimmed := bytes.TrimSpace(data); len(trimmed) == 0 || trimmed[0] == '{' { | ||
| return report, err | ||
| } | ||
| var yr struct { |
Member
There was a problem hiding this comment.
nit: ScanResult's yaml:"Files" tag is unused elsewhere; changing it to files would drop this struct.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mal diff --reportfailed on reports written with--format yaml:report.Loadonly parsed JSON, although the--reportfeature and the comment inaction.Diffsay JSON and YAML reports are supported.Changes
report.Loadstill tries JSON first. If that fails and the input is not empty and does not start with{, it reads the input as YAML, which the YAML renderer writes with its file reports underfiles.files, still returns the JSON error, soTestDiffReportErrorsand the existingTestLoadcases are unchanged.malcontent.ScanResultis unchanged; the YAML key is read through a local struct inLoad.Testing
TestLoadYAMLloads a report in the YAML renderer's shape and checks that non-report YAML still fails.TestDiffYAMLReportswrites both reports with the real YAML renderer and checks the removed, added, and modified keys.invalid character 'i' in literal false) and pass with it.go test -race ./pkg/... ./cmd/...passes, andmake golangci-lint-lintreports 0 issues.mal diff --reporton YAML reports of two directories produces output byte-identical to the same diff on the JSON reports, in both the terminal and JSON renderers.Fixes #1768