Repository navigation
feat!: make HttpError data-first with one constructor form - #21
Merged
Merged
Conversation
An HttpError is now its RFC 9457 data (status, title, detail, type,
instance, extensions, headers, expose) built from one options object, so
the TypeScript package and the coming Rust crate can share one shape.
conformance/vectors/problem-details.json pins the response every input
produces, how a problem response parses, and every status's default title
and detail; the TypeScript suite runs the vectors.
BREAKING CHANGE: the constructor takes only an options object:
new HttpError({ status, message, ... }). exposedMessage is renamed detail
and the detail option sets it; the name option is now title. statusText and
createHttpErrorClass are removed; extend HttpError for custom errors.
HttpError.from no longer copies a foreign error's name as the title, keeps
a response's status when its body is not Problem Details, and falls back to
the response's status when a problem's own status is not an error status.
Closes #18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPqZepyt7atNAZ12qoUeVS
A parsed problem's detail and a foreign error's detail were sent to the client even when the error was not exposed, so a server relaying an upstream 5xx leaked its detail. A parsed detail is now the message, which expose governs, and a foreign error's detail and headers are not copied. Assigning name sets the title instead of throwing; empty title, type and instance count as unset; a __proto__ extension serializes; a null standard member does not make a problem. The vectors now pin these, integral-float and byte-order-mark parsing, and use the RFC 9110 titles for 407 and 422. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YPqZepyt7atNAZ12qoUeVS
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YPqZepyt7atNAZ12qoUeVS
KyleJune
marked this pull request as ready for review
December 4, 2026 12:52
github-actions Bot
pushed a commit
that referenced
this pull request
Dec 4, 2026
## [0.13.0](0.12.1...0.13.0) (2026-12-04) ### ⚠ BREAKING CHANGES * make HttpError data-first with one constructor form (#21) ### Features * make HttpError data-first with one constructor form ([#21](#21)) ([093e25f](093e25f)), closes [udibo/oauth2#275](udibo/oauth2#275) [#19](#19)
|
🎉 This PR is included in version 0.13.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Requested by Kyle · project thread
Closes #18. Part of the Rust port plan (udibo/oauth2#275).
Why
HttpErrorhad four constructor overloads,namedoubling as the Problem Details title,exposedMessageas the public detail, astatusTextreason phrase and a class factory. A Rust crate can't share that shape. Now an error is just its RFC 9457 data, built from one options object, and a language-neutral vector file pins exactly what every input serializes to. The Rust crate (#19) will pass the same file.Outline
The rules stay the same:
exposedefaults to true for 4xx and false for 5xx, anddetailis the explicit detail, else the exposed message, else the status's stock sentence.What changed:
title,typeandinstancecount as unset.namesetstitle.HttpError.fromno longer takes a foreign error'snameas the title, so a HonoHTTPException(400)is titled "Bad Request", not "Error".fromnever copies a foreign error'sdetailorheaders. Before, anyHeadersor plain-object headers, includingset-cookieandcontent-length, were relayed to the client.detailbecomes the message, so an upstream 5xx detail stays private, as in 0.12.from(Response)keeps the response's status, unexposed.statusis not an error status falls back to the response's status, then 500.conformance/README.mdalso pins the parse edge cases another language would otherwise guess at: integer-valued floats, a byte-order mark,nullmembers, empty strings and a__proto__member.Verification
From
typescript/, Node 26:pnpm checkpasses.pnpm test:coveragepasses 107 tests at 100% statements and branches.src/conformance.test.tsruns every vector.pnpm buildandpnpm smokepass, with the smoke consumer updated to the new API.detailleaked pastexpose, that settingnamethrew, and that several parse cases were unpinned. All three are fixed ind688201, each with a vector or test that fails without the fix.The oauth2 update is built and passes oauth2's full suite (183 files, 6,132 tests) against this build. The udibo app is converted by a codemod (about 935 call sites,
tsc -bclean apart from an unrelated oauth2 catch-up). Both land in their own PRs after this releases.Risk
Door: one-way. This is a breaking change that releases 0.13.0 to npm and JSR (
feat!, a minor version while on 0.x). The only consumers are oauth2 and the udibo app, and both are updated before they take it.Tradeoffs
detailsentences instead of omittingdetailfor unexposed errors. Omitting it would makedetailoptional and break about 500 places in udibo that render it as a string. The vectors carry the table, so Rust copies it from there.getResponse()keeps its name to limit churn.https://claude.ai/code/session_01YPqZepyt7atNAZ12qoUeVS
Generated by Claude Code