Skip to content

fix: name the HTTP status when the error body is not JSON - #79

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

fix: name the HTTP status when the error body is not JSON#79
mogita merged 2 commits 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 on 8.0.0 saw StreamApiException: failed to parse error response for a 503 that the edge proxy returned as plain text, with a Jackson JsonParseException cause, and could not tell which status they got. StreamException.build(Response) now appends the status: failed to parse error response: unexpected server response code 503. getStatusCode(), getRawResponseBody() and the 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.

build(ResponseBody) keeps the old message. That overload does not receive the status, and its javadoc already tells callers to prefer build(Response).

Verification

  • ./gradlew spotlessCheck: pass.
  • ./gradlew test --tests io.getstream.StreamErrorHandlingTest: 11 tests, 0 failures.
  • ./gradlew build: the integration test classes fail on initializationError: apiKey and apiSecret are required, which needs credentials. The base commit behaves the same.

Also in this PR: a red test on main, not caused by this change

ModerationTest > Can flag activity and Can check activity content fail on main too, in the scheduled run of 2026-08-10 (run 31375353948, same 464 tests completed, 2 failed, 23 skipped). Last green run on main was 2026-08-03.

Cause: testBanWithReason globally banned the shared testUserId for 60 minutes, and a banned user cannot add an activity. The two tests above create an activity as that user, so they failed whenever JUnit ran them after the ban test. The ban and unban tests now target a dedicated bannedUserId, which keeps the ban out of the shared fixture.

The doc snippets keep the same shape; only the target user variable changes.

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.

The build(ResponseBody) overload keeps the old message, because it does
not receive the status.
ModerationTest banned the shared testUserId for 60 minutes, and a banned
user cannot add an activity. The two tests that create an activity as
that user failed whenever they ran after the ban test. The ban and unban
tests now target a dedicated user.
@mogita
mogita merged commit a49641c into main Aug 12, 2026
4 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 12, 2026
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