Skip to content
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

json-formatter: fix error message #594

Merged
merged 1 commit into from
Apr 5, 2021
Merged

Conversation

m-ildefons
Copy link
Collaborator

Fix message field in output by json formatter in case of errors
preventing rule application (e.g. parsing errors).

Previously, a pretty printing method from Text.Megaparsec.Error was
used, but this decorated the message with junk characters. The new
errorMessage function converts a ParseErrorBundle into a printable
String without additional junk, stripping newlines from the end as
well.

fixes: #593

How to verify it

Executing hadolint -f json Dockerfile for the following Dockerfile should yield [{"line":1,"code":"DL1000","message":"missing whitespace","column":4,"file":"/home/moritz/tmp/Dockerfile","level":"error"}]:

RUNNN

Fix `message` field in output by json formatter in case of errors
preventing rule application (e.g. parsing errors).

Previously, a pretty printing method from `Text.Megaparsec.Error` was
used, but this decorated the message with junk characters. The new
`errorMessage` function converts a `ParseErrorBundle` into a printable
`String` without additional junk, stripping newlines from the end as
well.

fixes: hadolint#593
@lorenzo
Copy link
Member

lorenzo commented Apr 5, 2021

Great job!

@lorenzo lorenzo merged commit beb74eb into hadolint:master Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

json "message" field incorrect for "missing whitespace" error
2 participants