Skip to content

fix: read an error body by its code, not by a message - #29

Merged
maxholman[bot] merged 1 commit into
masterfrom
fix/error-body-without-message
Nov 8, 2026
Merged

maxholman[bot] merged 1 commit into
masterfrom
fix/error-body-without-message

Conversation

@maxholman

@maxholman maxholman Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Since 7dbede2 (v13.0.0), ServiceError.fromResponse reads a body's code and details only when the body has a message. That condition came from the old send() path, while json() had read any body with a code.

A server using the standard error body sends { code, details } and never the thrown message, which can leak internals. So every such error reached clients as UNKNOWN, with an http-<status> detail.

fromResponse now:

  • reads a body with a status code;
  • keeps its details;
  • takes the error's message from the first localised detail, or the status text when there is none.

It never reads a top-level message.

The test server's JSON error fixture now sends the standard body. There are new tests for a body with a localised detail, a body without one, and a body that isn't an error body.

7dbede2 merged json()'s and send()'s error handling into
`ServiceError.fromResponse`, keeping send()'s `"message" in body`
test. json() had read any body with a `code`, as servers send them:
`{ code, details }`, never the thrown message, which can leak
internals. Since then such a body lost its code and details and read
as UNKNOWN.

`fromResponse` again reads a body with a status `code`, keeps its
details, and takes its message from the first localised detail, or
the status text.

Co-Authored-By: LLM <noreply@block65.dev>
@maxholman
maxholman Bot merged commit 6a93686 into master Nov 8, 2026
5 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