Skip to content

descriptor, codegen: allow MessageSet extension field numbers up to i32::MAX - #810

Open
Divyansh151005 wants to merge 1 commit into
anthropics:mainfrom
Divyansh151005:fix/message-set-extension-field-number-702
Open

Divyansh151005 wants to merge 1 commit into
anthropics:mainfrom
Divyansh151005:fix/message-set-extension-field-number-702

Conversation

@Divyansh151005

@Divyansh151005 Divyansh151005 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #702.

What this does

MessageSet extensions carry their type id as an int32, so protoc allows extension numbers up to i32::MAX on messages with message_set_wire_format = true. buffa previously capped every extension at (1 << 29) - 1 in both DescriptorPool::link_extension and codegen for extend, so descriptors protoc accepts were rejected or failed to generate.

This change passes a per-call upper bound into link_field: i32::MAX when the extendee is a MessageSet, otherwise MAX_FIELD_NUMBER. Codegen uses the same rule via validated_extension_field_number, resolving the extendee message in the input descriptor set.

Testing

Rust 1.95.0 (rust-toolchain.toml).

cargo fmt --all --check
cargo test -p buffa-codegen message_set_extension_const
cargo test -p buffa-descriptor --test message_set_extension_field_number --features reflect
cargo clippy -p buffa-codegen -p buffa-descriptor --features buffa-descriptor/reflect -- -D warnings

Results: both unit tests passed (message_set_extension_const_uses_large_field_number, message_set_extension_above_max_field_number_links); fmt and clippy completed with no warnings.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

…::MAX

Match protoc's relaxed field-number bound for extensions of message_set_wire_format messages in the pool linker and extension codegen.
@Divyansh151005
Divyansh151005 force-pushed the fix/message-set-extension-field-number-702 branch from ec91f20 to 8cda375 Compare October 29, 2026 15:01

This branch has not been deployed

No deployments
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.

codegen, descriptor: an extension of a message_set_wire_format message cannot have a number above 2^29 - 1

1 participant