fix: name the HTTP status when the error body is not JSON - #79
Merged
Conversation
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.
mogita
force-pushed
the
fix/cha-4641-error-status-in-message
branch
from
August 12, 2026 18:01
7755351 to
8d23ed8
Compare
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.
Merged
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.
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 responsefor a 503 that the edge proxy returned as plain text, with a JacksonJsonParseExceptioncause, 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 preferbuild(Response).Verification
./gradlew spotlessCheck: pass../gradlew test --tests io.getstream.StreamErrorHandlingTest: 11 tests, 0 failures../gradlew build: the integration test classes fail oninitializationError: 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 activityandCan check activity contentfail onmaintoo, in the scheduled run of 2026-08-10 (run 31375353948, same464 tests completed, 2 failed, 23 skipped). Last green run on main was 2026-08-03.Cause:
testBanWithReasonglobally banned the sharedtestUserIdfor 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 dedicatedbannedUserId, which keeps the ban out of the shared fixture.The doc snippets keep the same shape; only the target user variable changes.