-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Stop swallowing JSON parse errors #67
Conversation
Edited to add context, fyi (GitHub posted this PR from their editor without a description) |
@@ -65,7 +65,7 @@ def verify_array_index!(path, index, size) | |||
def safe_json_parse(data) | |||
JSON.parse(data) | |||
rescue JSON::ParserError | |||
nil | |||
raise JSON::ParserError, "Malformed JSON in multipart form data" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is no longer safe, so let's remove it and use JSON.parse directly where needed.
I don't remember why it was done like this, so yes, let's try to remove safety :) |
thanks for your patience -- feedback addressed and ready for re-review. |
Thank you. |
@@ -6,3 +6,4 @@ | |||
/pkg/ | |||
/spec/reports/ | |||
/tmp/ | |||
/vendor/bundle/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Common path for local gems to be stored
example.run | ||
described_class.strict_mode = mode | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly not sure what changed here, tabs and line endings seem unaltered 🤷
View the diff with ?w=1
in URL params to show actual changes.
Done! I basically just changed |
Looks good. Thank you for the contribution! |
If unparseable JSON is provided, the library should fail loudly rather than ignoring the input.
Looking through the blame, I couldn't find any specific reason why
safe_json_parse
is meant to be safe -- in fact, because it swallows up errors and pretends that there's no problem, it made things very confusing to diagnose.Let me know if you'd like me to take this in any particular direction and I'm happy to update the PR.