Skip to content

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

Merged
mogita merged 1 commit 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#137
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. StreamError.Message now appends the status: failed to parse error response: unexpected server response code 503. StatusCode, RawResponseBody and the parse 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.

Second fix in the same branch: json.Unmarshal can assign fields before it errors, so a half-parsed body could leave StatusCode wrong on this path. The transport status is now restored.

Verification

  • go test -short -race ./...: pass.
  • go mod tidy: no change to go.mod or go.sum.
  • golangci-lint run ./...: same 24 pre-existing issues as the base commit, none at the changed lines.

@mogita
mogita requested a review from tbarbugli as a code owner August 12, 2026 17:39
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 17:39 — with GitHub Actions Active
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 17:39 — with GitHub Actions Active
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 17:39 — with GitHub Actions Active
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 17:39 — with GitHub Actions Active
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 17:39 — with GitHub Actions Active
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 17:39 — with GitHub Actions Active
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.

A failed Unmarshal can assign fields before it errors, so the transport
status is restored instead of the partial parse result.
@mogita
mogita force-pushed the fix/cha-4641-error-status-in-message branch from e7a7605 to 3dc3ba9 Compare August 12, 2026 18:01
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 18:01 — with GitHub Actions Active
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 18:01 — with GitHub Actions Active
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 18:01 — with GitHub Actions Active
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 18:01 — with GitHub Actions Active
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 18:01 — with GitHub Actions Active
@mogita
mogita deployed to feeds-enabled-shard August 12, 2026 18:01 — with GitHub Actions Active
@mogita
mogita merged commit 7f6ed96 into main Aug 12, 2026
11 of 12 checks passed
@mogita
mogita deleted the fix/cha-4641-error-status-in-message branch August 12, 2026 18:52
@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