Skip to content

feat(truapi): refuse a request in a version the host does not know - #1650

Merged
Mikelle merged 30 commits into
mainfrom
feat/unsupported-version-error
Oct 26, 2026
Merged

Mikelle merged 30 commits into
mainfrom
feat/unsupported-version-error

Conversation

@Mikelle

@Mikelle Mikelle commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes https://github.com/paritytech/platform-bugs/issues/123

A product built against a newer protocol can send a request version the host doesn't know. The host refuses it with an UnsupportedVersion protocol error, and the call fails as Unsupported, like an unknown method.

  • The dispatcher checks the request's first byte, which is its version, before running the handler. The refusal is [0, 1, trait, method, newest_version] on (255, 255), and the host logs it once per method.
  • The dispatcher decodes requests for the handlers, so the generated dispatcher no longer repeats the decode step for every method (about 900 lines less).
  • The product SDK settles the call as Unsupported and logs the newest version the host accepts.

Existing messages don't change. Apps released before this still answer MalformedFrame.

A host refuses a request or subscription start in a version newer than it
knows with an `UnsupportedVersion` protocol error, before handling it, and
names the newest version it accepts.

Handlers now take their decoded request. `on_request` and `on_subscription`
infer the request type from the handler, decode the payload, answer bytes
that do not decode with `MalformedFrame`, and record the type's
`Versioned::LATEST`. The dispatcher checks the version byte after reserving
the call, so duplicate ids and early withdrawals are handled as for any other
request. Generated handlers no longer carry their own decode step.

The TS transport decodes the new error from a codec declared like the Rust
enum, settles the refused call as `Unsupported` as it does for
`UnsupportedMessage`, and warns with the newest version the host accepts. The
Rust decoder reads the known variants from the enum's type information. A
host built before this answers such a request with `MalformedFrame`.
@Mikelle
Mikelle requested a review from a team October 22, 2026 14:58
@github-actions github-actions Bot added documentation Improvements or additions to documentation javascript Pull requests that update javascript code rust Pull requests that update rust code labels Oct 22, 2026
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Bundle size report

Compared with main at cc8aa21.

Raw Gzip Brotli
truapi-host 8.10 MiB (+31.8 KiB, +0.4%) 5.73 MiB (+8.9 KiB, +0.2%) 5.43 MiB (+5.5 KiB, +0.1%)
truapi-provider 4.03 MiB 1.27 MiB 960.2 KiB
truapi 6.72 MiB (+1.5 KiB) 951.5 KiB (+423 B) 777.8 KiB (+406 B, +0.1%)
trinity-stack 562.4 KiB 225.5 KiB 186.6 KiB
Total 19.41 MiB (+33.3 KiB, +0.2%) 8.15 MiB (+9.3 KiB, +0.1%) 7.31 MiB (+5.9 KiB, +0.1%)

WebAssembly modules

Raw Gzip Brotli
truapi-host/wasm/web/truapi_server_bg.wasm 2.99 MiB (+31.8 KiB, +1.0%) 1.04 MiB (+8.9 KiB, +0.8%) 793.8 KiB (+5.5 KiB, +0.7%)
truapi-host/wasm/web/truapi_verifiable_bg.wasm 4.89 MiB 4.64 MiB 4.61 MiB
truapi-provider/truapi_provider_bg.wasm 3.99 MiB 1.26 MiB 952.5 KiB
trinity-stack/wasm/trinity_stack_bg.wasm 525.1 KiB 217.1 KiB 179.3 KiB
Changed files (4)
Raw Gzip Brotli
truapi-host/wasm/web/truapi_server_bg.wasm 2.99 MiB (+31.8 KiB, +1.0%) 1.04 MiB (+8.9 KiB, +0.8%) 793.8 KiB (+5.5 KiB, +0.7%)
truapi/client.js 34.2 KiB (+1.1 KiB, +3.2%) 8.3 KiB (+279 B, +3.4%) 7.1 KiB (+244 B, +3.5%)
truapi/scale.js 5.7 KiB (+254 B, +4.5%) 2.2 KiB (+87 B, +4.0%) 1.9 KiB (+85 B, +4.5%)
truapi/playground/codegen/truapi-dts.js 338.3 KiB (+174 B, +0.1%) 57.7 KiB (+57 B, +0.1%) 46.2 KiB (+77 B, +0.2%)

Commit: e14e635

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

CI Status: 24 required jobs green, 21 passed and 3 skipped by path filter.

All job results
job result
android-app success
android-bindings success
bundle-size success
changes success
changeset-guard success
cli-package success
codegen success
e2e skipped
explorer success
headless-install success
host-wasm success
ios-app success
ios-bindings success
licenses success
playground success
provider-android-bindings skipped
release-guard success
rust success
ts-client success
ts-debugger success
ts-host success
ts-trinity-stack success
wasm-provider success
workflow-lint skipped

Signing credentials: valid as of 2026-10-26

Commit e14e6350 · run log

@Mikelle Mikelle self-assigned this Oct 23, 2026
Comment thread docs/design/truapi-protocol.md
@Mikelle
Mikelle enabled auto-merge October 26, 2026 21:48
@Mikelle
Mikelle added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 747865c Oct 26, 2026
47 checks passed
@Mikelle
Mikelle deleted the feat/unsupported-version-error branch October 26, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation javascript Pull requests that update javascript code rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants