Skip to content

fix: rescue JSON::ParserError in response hook - #354

Merged
Justin Hammond (Justintime50) merged 1 commit into
masterfrom
fix_json_parser_error
Nov 6, 2026
Merged

Justin Hammond (Justintime50) merged 1 commit into
masterfrom
fix_json_parser_error

Conversation

@Justintime50

@Justintime50 Justin Hammond (Justintime50) commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

A subscribed response hook rescued JSON::ParseError, which the json gem does not define, so a non-JSON body raised NameError instead of falling through as the raw body. Rescue JSON::ParserError instead.

Testing: Reproduced the NameError on master with the issue's script (json 2.21.2); after the fix the raw body is passed to the hook. just lint and just test pass.

Fixes #353

@Justintime50
Justin Hammond (Justintime50) marked this pull request as ready for review November 6, 2026 18:15
JSON::ParseError is not defined by the json gem, so a subscribed
response hook and a non-JSON body raised NameError instead of
falling back to the raw body.
Comment thread lib/easypost/http_client.rb Resolved
@Justintime50
Justin Hammond (Justintime50) merged commit 996a936 into master Nov 6, 2026
12 checks passed
@Justintime50
Justin Hammond (Justintime50) deleted the fix_json_parser_error branch November 6, 2026 21:24
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.

HttpClient response hook rescues undefined JSON::ParseError (should be JSON::ParserError)

2 participants