Skip to content

fix: decode problem details responses as strict UTF-8 - #26

Merged
KyleJune merged 2 commits into
mainfrom
claude/project-thread-uz7ea9
Dec 5, 2026
Merged

KyleJune merged 2 commits into
mainfrom
claude/project-thread-uz7ea9

Conversation

@KyleJune

@KyleJune KyleJune commented Dec 5, 2026

Copy link
Copy Markdown
Member

Requested by Kyle · project thread

Summary

Defines the byte encoding of a Problem Details response: the body is decoded as strict UTF-8, allowing one leading UTF-8 byte-order mark. A body that is not valid UTF-8 (Latin-1, UTF-16, ...) now gets the same unexposed fallback as an unparsable JSON body.

  • TypeScript (fix): HttpError.from(response) decoded with response.json(), which replaces invalid bytes. A Latin-1 body such as {"title":"Caf\xe9","status":422} became an exposed 422 titled Caf�. It now decodes with a fatal TextDecoder and returns the unexposed fallback with the response's status.
  • Rust: already matched; native tests now pin a Latin-1 body and a doubled byte-order mark.
  • Conformance: a parse input now takes exactly one of body (text) or body_hex (exact bytes). Four byte cases added: utf8, utf8-bom, utf16le-bom, latin1-in-title. Both runners build the response from those bytes before calling the public parser.
  • TypeScript README: documents the strict decoding and the number contract (integers in the I-JSON range are exchanged exactly; send larger ones as decimal strings).

Constructors that take decoded values are unchanged.

Release note

A non-UTF-8 problem details response body now yields the unexposed fallback error instead of a problem with replacement characters.

Testing

  • TypeScript: pnpm check, vitest run (124 passed). The latin1-in-title vector fails without the mod.ts change.
  • Rust: fmt, clippy -D warnings, cargo test --workspace --all-features.

Generated by Claude Code

Parse inputs take body or body_hex, and four byte cases pin strict UTF-8
with one optional byte-order mark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPqZepyt7atNAZ12qoUeVS
A Response body that is not valid UTF-8 now gives the unexposed fallback
instead of a problem with replacement characters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPqZepyt7atNAZ12qoUeVS
@KyleJune KyleJune self-assigned this Dec 5, 2026
@KyleJune
KyleJune marked this pull request as ready for review December 5, 2026 16:42
@KyleJune
KyleJune merged commit 68519bc into main Dec 5, 2026
32 checks passed
github-actions Bot pushed a commit that referenced this pull request Dec 5, 2026
## [0.13.1](0.13.0...0.13.1) (2026-12-05)

### Bug Fixes

* decode problem details responses as strict UTF-8 ([#26](#26)) ([68519bc](68519bc))
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 0.13.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants