Skip to content

fix(javascript): accept user type id 0 in struct, ext, and enum factories - #4014

Merged
chaokunyang merged 3 commits into
apache:mainfrom
ayush00git:fix/user-type-id-zero
Sep 3, 2026
Merged

fix(javascript): accept user type id 0 in struct, ext, and enum factories#4014
chaokunyang merged 3 commits into
apache:mainfrom
ayush00git:fix/user-type-id-zero

Conversation

@ayush00git

Copy link
Copy Markdown
Contributor

What was the error

Type.struct(0, ...), Type.ext(0), and Type.enum(0, ...) threw type name and type id should be set at least one because a truthiness check treated the numeric id 0 as absent, although TypeInfo allows user type ids in [0, 0xfffffffe]. A peer runtime registering a type under id 0 could not interoperate with JavaScript.

What this PR fixes

The three factories now check typeId === undefined instead of truthiness, so id 0 registers normally. A regression test covers all three factories and a full serialize/deserialize round trip under id 0.

…ries

Type.struct(0, ...), Type.ext(0), and Type.enum(0, ...) threw because a
truthiness check treated the id 0 as absent, although TypeInfo documents
user type ids in [0, 0xfffffffe]. Check for undefined instead.
@chaokunyang
chaokunyang merged commit dd5e2e9 into apache:main Sep 3, 2026
38 checks passed
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.

2 participants