Skip to content

fix: flat error wire#285

Draft
decrypto21 wants to merge 2 commits into
mainfrom
fix/flat-error-wire
Draft

fix: flat error wire#285
decrypto21 wants to merge 2 commits into
mainfrom
fix/flat-error-wire

Conversation

@decrypto21

Copy link
Copy Markdown

DRAFT - do not merge. Gate: the release-direction decision (restore flat vs the #259 versioned tier) and this reverts published releases. Tracked as the reference/core-side (D4) divergence in #271.

What
Error responses and subscription interrupts now carry the flat domain error on the wire, matching the Ok arm's hoisted version tag and the shape every deployed host and the 0.3.x client line already speak:

Framework-level CallError variants (Denied, Unsupported, MalformedFrame, HostFailure) fold into the method's domain catch-all. The codegen resolves each method's catch-all constructor from the extracted enum variants and fails loudly for error enums that have none. The reason is preserved where the catch-all carries one (Unknown { reason } or Unknown(GenericError)); a unit catch-all (e.g. CoinPaymentError::Internal) has nowhere to carry it, so the reason is dropped and the framework variants collapse onto that one discriminant - documented at the fold site and on the variant.

@parity/truapi 0.4.0 (#279), 0.4.1 (#284), and @parity/truapi-host 0.1.0 (#278) shipped a richer, tiered CallError shape. Clients on the flat 0.3.x decoder read the new tagged variants positionally and silently mis-map them - no crash, wrong meaning. Executed byte-evidence:

PartialPayment{…} → decoded as InsufficientFunds
Denied{reason} → decoded as InvalidSource
The fleet is safe only because product-sdk-host pins @parity/truapi: ^0.3.2 - the caret caps below 0.4.x. The misread goes live on the first bump past 0.3.x (or when host-api-test-sdk#40 adopts 0.1.0) - and 0.4.1 bundling the Firefox iframe fix (#283) now gives a concrete reason to bump.

Evidence
Re-ran the differential probe against this commit and the fixed novasama host:

Scope
The scratch differential-probe crate (rust/crates/probe/), the Cargo.lock bump, and the pub mod dispatcher visibility tweak are local-only and deliberately not part of this PR.

Relates to #271 (D4)

Error responses and subscription interrupts carry the flat domain error on
the wire — [version][Err][domain bytes] for responses, [version][domain
bytes] for interrupts — matching the Ok arm's hoisted version tag and the
shape every deployed host and the 0.3.x client line speak. Framework-level
CallError variants (Denied, Unsupported, MalformedFrame, HostFailure) fold
into the method's domain catch-all with their reason preserved; the codegen
resolves each method's catch-all constructor (Unknown { reason },
Unknown(GenericError), or a unit Internal) from the extracted enum variants
and fails loudly for error enums that have none.

Natural end of a subscription stream no longer emits an empty interrupt
frame; only an explicit interrupt carries a terminal frame.

The generated TS client decodes the same flat shape, and the handshake
codec in client.ts matches. The scale.ts CallError codec is gone from the
public surface: CallError never appears on the wire.

Differential conformance probes (truapi-server dispatcher vs the novasama
host-container at triangle-js-sdks 592dc4b) now produce byte-identical
error frames for the same domain error, and the published @parity/truapi
0.3.2 codecs decode the core's frames correctly (previously
Domain(PartialPayment) silently decoded as InsufficientFunds).
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