Skip to content

feat: name the HTTP status when the error body is not JSON - #58

Merged
mogita merged 1 commit into
masterfrom
fix/cha-4641-error-status-in-message
Aug 12, 2026
Merged

feat: name the HTTP status when the error body is not JSON#58
mogita merged 1 commit into
masterfrom
fix/cha-4641-error-status-in-message

Conversation

@mogita

@mogitamogita commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Ticket

https://linear.app/stream/issue/CHA-4641/generated-sdks-report-the-http-status-when-the-error-body-is-not-json

Summary

When an error body is not JSON, the SDK reported only the parse failure and hid the HTTP status. A customer saw failed to parse error response for a 503 that the edge proxy returned as plain text, plus a JSON parse stack trace, and could not tell which status they got. The message now appends the status: failed to parse error response: unexpected server response code 503. getStatusCode(), getRawResponseBody() and the \JsonException cause do not change.

The old text is still the prefix of the new message, so prefix matching and substring matching on it both keep working. The integration assertion that uses str_contains still holds.

Verification

  • make lint (PHPStan): no errors.
  • vendor/bin/phpunit tests/Exceptions/ErrorHandlingTest.php: 16 tests, 47 assertions, pass.
  • make test-unit: 2 errors in ClientTest, which need STREAM_API_SECRET. The base commit gives the same 2 errors.

An unparseable error body produced the message "failed to parse error
response", which hid the HTTP status. The message now appends the status
to that text, so prefix matching and substring matching both keep
working. The status code, the raw response body and the parse cause do
not change.
@mogita
mogitaforce-pushed the fix/cha-4641-error-status-in-message branch from 676013d to fd5ef00CompareAugust 12, 2026 18:01
@mogitamogita changed the title fix: name the HTTP status when the error body is not JSONfeat: name the HTTP status when the error body is not JSONAug 12, 2026
@mogita
mogita merged commit 585e4e0 into masterAug 12, 2026
7 checks passed
@mogita
mogita deleted the fix/cha-4641-error-status-in-message branch August 12, 2026 18:49
github-actionsBot added a commit that referenced this pull request Aug 12, 2026
Sign up for freeto 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.

1 participant

@mogita