Repository navigation
descriptor: reject an editions file whose edition is outside the supported range - #798
Open
saloni-garg wants to merge 2 commits into
Open
saloni-garg wants to merge 2 commits into
saloni-garg wants to merge 2 commits into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
saloni-garg
marked this pull request as ready for review
October 26, 2026 05:12
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #634. An editions file whose edition is outside
EDITION_PROTO2throughEDITION_2024linked without error and resolved its features with the edition 2023 defaults. That held both for defined values the pool does not support (EDITION_UNSTABLE, the*_TEST_ONLYvalues,EDITION_MAX,EDITION_LEGACY) and for numbers this version of buffa does not define at all, like a future edition 1002, which decoding keeps as an unknown field. The 2023 defaults are right for a later edition only while that edition changes no runtime feature default, which the pool cannot know. protoc and protobuf-go both reject an edition above their supported maximum.Change
buffa-descriptor/src/pool.rs: the syntax check inadd_file_descriptor_setnow reads the file's edition number as written (a newedition_numberhelper replaceshas_edition; an undefined number is recovered from the unknown fields, where the closedEditionenum leaves it). An unset number orEDITION_UNKNOWNis stillPoolError::MissingEdition; any other number outsideEDITION_PROTO2..=EDITION_2024is the newPoolError::UnsupportedEdition { file, edition }.EDITION_PROTO2(998), soEDITION_LEGACY(900) in an editions-syntax file is rejected too, even thoughfeatures::for_editionmaps it to the proto2 defaults for direct callers. Happy to carve it out if you would rather keep it.editions_file_with_an_undefined_edition_number_links_with_2023_defaultspinned the lenient behaviour; it now asserts the rejection, including the error'sDisplaytext, and keeps its wire-level construction (a hand-written unknown field for edition 5000, encoded and decoded). New tests inbuffa-descriptor/tests/pool_unsupported_edition.rscover the defined-but-unsupported values, a wire-encoded undefined number (1002), the four supported editions still linking, the missing-edition cases, and the gate not applying to non-editions files.MissingEditiondocs and thefeatures::for_filedoc mention the new rejection; a changelog fragment is under.changes/unreleased/.This is independent of #797 (the relative
type_nameresolution fix); the two touch different parts ofpool.rs.Test report
Before the fix, a probe test linking editions files with
EDITION_UNSTABLE,EDITION_1_TEST_ONLYandEDITION_MAXpassed (all three linked) on unpatched main. After the fix:(buffa-codegen, buffa-build, buffa and buffa-types suites, 2222 tests, pass with the combined tree; this change adds a
PoolErrorvariant and narrows what the pool accepts, and nothing in those crates matchesPoolErrorexhaustively.)One heads-up: this repo has a CLA (CLA.md). I have not signed it, so the CLA check is Saloni's to complete if you want this merged.
This change was prepared with AI assistance; the repro and test results above were run and checked by the author.