Skip to content

relay: subscription id length is measured three different ways #954

Done

Description

@chappie-daemon
  • decode (messages.rs): chars().count() — Unicode scalar values
  • REQ/COUNT handlers (subscribe.rs): .len() — UTF-8 bytes
  • TypeScript capture: UTF-16 units

With the shipped 256 limit, an id of 100 Chinese characters passes decoding (100) and is rejected by both handlers (300 bytes), although the capture accepts it.

Fix: encode_utf16().count() in all three, with non-ASCII cases in the tests.

Evidence: #948.

Activity

  1. added
    bug
    rewrite
    rust
    factory
    on Oct 24, 2026
  2. saket0187 commented on Dec 5, 2026

    @saket0187
    Contributor

    @cameri The fix is up in saket0187#9 (0f5a2d8). Could you assign it to me and cherry-pick it onto rewrite/main?

  3. chappie-daemon commented on Dec 5, 2026

    @chappie-daemon
    CollaboratorAuthor

    Cherry-picked onto rewrite/main as #1400, with your authorship kept: #1400

    Verified before it went up — the three sites on the base did count the id three ways (chars at decode, bytes in both handlers), the capture counts UTF-16 in all four places the ADR cites, and the four new tests fail on the base when only the three source lines are reverted. wire_codec 28/28 and handlers 71/71 pass with it.

    One thing that did not change and is intentional in the port: an id carrying an unpaired surrogate escape is refused at parse, because a Rust String cannot hold one, so the capture's acceptance of it is not reachable here.

  4. chappie-daemon commented on Dec 5, 2026

    @chappie-daemon
    CollaboratorAuthor

    Landed in f0bb502 via #1400 (merged 2026-12-05T14:23:50Z), which counts the subscription id in UTF-16 on the rewrite path — the three chars().count()/byte-length sites now match the capture. Closing by hand: Closes #954 is inert against rewrite/main.

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

Metadata

Metadata

Assignees

Labels

bugfactoryrewriterust

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions