Skip to content

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

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

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

Conversation

@mogita

@mogita mogita commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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. StreamApiException.message now appends the status: failed to parse error response: unexpected server response code 503. status_code, raw_response_body and __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.

Verification

  • make lint: ruff check and format clean.
  • uv run pytest tests/test_exceptions.py tests/test_retry.py: 53 passed.
  • make typecheck: 61 diagnostics, the same count as the base commit.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a40ed371-9725-4115-96ff-2d22a30079fe

📥 Commits

Reviewing files that changed from the base of the PR and between dfbfaf8 and 7e5b7c9.

📒 Files selected for processing (2)
  • getstream/exceptions.py
  • tests/test_exceptions.py

📝 Walkthrough

Walkthrough

Malformed API response errors now include the HTTP status code. The exception documentation and fallback implementation use the updated message format. The test expects status 500 in the generated error.

Changes

API error reporting

Layer / File(s) Summary
Include status codes in parse-failure errors
getstream/exceptions.py, tests/test_exceptions.py
The documented and generated parse-failure messages now include the HTTP response status code. The fallback test verifies status 500 in the error message.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: including the HTTP status when the error body is not JSON.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cha-4641-error-status-in-message

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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 mogita changed the title fix: name the HTTP status when the error body is not JSON feat: name the HTTP status when the error body is not JSON Aug 12, 2026
@mogita
mogita merged commit b5499a8 into main Aug 12, 2026
28 checks passed
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.

1 participant