Support protobuf 7 by routing major >= 6 to the v6 gencode#183
Open
plusky wants to merge 1 commit into
Open
Conversation
Protobuf's cross-version runtime guarantee (https://protobuf.dev/support/cross-version-runtime-guarantee) makes gencode forward-compatible with newer runtimes: ValidateProtobufRuntimeVersion only rejects a runtime that is OLDER than the linked gencode, never a newer one. The strict 'major == 6' dispatch in xai_sdk.proto therefore rejected protobuf 7.x unnecessarily, raising 'Unsupported protobuf version: 7.x' on distributions that already ship protobuf 7 (openSUSE Tumbleweed, Arch Linux). Route major >= 6 to the v6 stubs and relax the pyproject cap to <8 accordingly. Verified by running the full test suite (763 tests) against protobuf 7.34.2.
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.
Problem
On distributions that already ship protobuf 7.x (openSUSE Tumbleweed with 7.34.2, Arch Linux with 7.35.1), importing the SDK fails:
raised by the strict
major == 6dispatch insrc/xai_sdk/proto/__init__.py.Why this is safe
Per protobuf's cross-version runtime guarantee, gencode is forward-compatible with newer runtimes:
ValidateProtobufRuntimeVersiononly rejects a runtime that is older than the linked gencode, never a newer one. So the bundled v6 stubs load and work fine on the protobuf 7 runtime — only the SDK's own dispatch was rejecting it.Change
major >= 6to the v6 stubs instead ofmajor == 6pyproject.tomlcap fromprotobuf<7to<8accordinglyVerification
Full test suite (763 tests, mock gRPC server) passes against protobuf 7.34.2 on Python 3.13 and 3.14 (run while packaging the SDK for openSUSE).