Preserve JSON parse failure context in error responses#66
Merged
Conversation
When a server returns a non-JSON error body (HTML proxy error, truncated JSON), the exception should surface both the parse failure reason and the raw response content. These tests verify that behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When JSON::decode_json() fails on a server error response body (e.g., an
HTML proxy error page or truncated JSON), the parse failure was silently
swallowed and the bare HTTP::Protocol exception re-thrown. This lost the
context needed to diagnose why the ACME error couldn't be extracted.
Now when JSON parsing fails, _xform_http_error creates a Generic exception
that includes both the parse error reason and the raw response content,
with the original HTTP::Protocol exception accessible via get('http').
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
What
When
_xform_http_error()can't parse the server's error response as JSON, theexception now includes the parse failure reason and raw response content.
Why
Servers sometimes return non-JSON error bodies (HTML proxy errors, truncated
JSON, rate-limit pages). Previously,
JSON::decode_json()failure was silentlyswallowed and the bare
HTTP::Protocolexception re-thrown — making it hard todiagnose what the server actually said.
How
When JSON decoding fails,
_xform_http_error()now creates anX::Genericexception that includes the parse error message and raw content, with the
original
HTTP::Protocolexception accessible via->get('http').Testing
🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 130 insertions(+), 2 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline