Skip to content

Support protobuf 7 by routing major >= 6 to the v6 gencode#183

Open
plusky wants to merge 1 commit into
xai-org:mainfrom
plusky:protobuf-7-dispatch
Open

Support protobuf 7 by routing major >= 6 to the v6 gencode#183
plusky wants to merge 1 commit into
xai-org:mainfrom
plusky:protobuf-7-dispatch

Conversation

@plusky

@plusky plusky commented Jul 16, 2026

Copy link
Copy Markdown

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:

ValueError: Unsupported protobuf version: 7.34.2

raised by the strict major == 6 dispatch in src/xai_sdk/proto/__init__.py.

Why this is safe

Per protobuf's cross-version runtime guarantee, gencode is forward-compatible with newer runtimes: ValidateProtobufRuntimeVersion only 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

  • Route major >= 6 to the v6 stubs instead of major == 6
  • Relax the pyproject.toml cap from protobuf<7 to <8 accordingly

Verification

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).

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.
@plusky
plusky requested a review from a team as a code owner July 16, 2026 11:55
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.

1 participant