Skip to content

proto: install and run with protobuf 7.x - #235

Closed
deanrie wants to merge 1 commit into
xai-org:mainfrom
deanrie:protobuf-7
Closed

deanrie wants to merge 1 commit into
xai-org:mainfrom
deanrie:protobuf-7

Conversation

@deanrie

@deanrie deanrie commented Oct 23, 2026

Copy link
Copy Markdown

What

pyproject.toml pins protobuf>=5.29.4,<7, and src/xai_sdk/proto/__init__.py routes only major == 6 to the 6.x generated modules, raising ValueError("Unsupported protobuf version") for anything newer. An environment that already has protobuf 7 cannot resolve the SDK at all; the resolver stops at the pin before any code runs.

Why the 6.x gencode is enough

protobuf's runtime check (google.protobuf.runtime_version.ValidateProtobufRuntimeVersion, 7.36.2) refuses two things: a gencode/runtime domain mismatch, and a runtime that is older than the gencode it loads. A newer runtime loading older gencode is the supported direction, so the modules generated with 6.30.0 import on 7.x without a warning. No regenerated stubs are needed.

Change

  • protobuf>=5.29.4,<8 in pyproject.toml (and the matching requires-dist line in uv.lock; the resolved dev version is unchanged).
  • _PROTOBUF_MAJOR >= 6 selects the v6 modules; == 5 and the ValueError for older runtimes are unchanged.
  • CHANGELOG entry under Unreleased / Changed.

Verification

  • Full suite under protobuf 6.31.1 (project venv): 867 passed.
  • Full suite under protobuf 7.36.2 (separate venv, uv pip install -e . 'protobuf>=7,<8'): 867 passed, and -W error::UserWarning stays green, so the 7.x runtime emits no gencode warnings for the v6 modules.
  • tests/proto_test.py reloads xai_sdk.proto with the runtime version patched: 7.0.0, 7.36.0 and 8.1.0 select v6 (these three fail on main with the ValueError), 6.31.1 selects v6, 5.29.4 selects v5, 4.25.0 is still rejected.
  • ruff check, ruff format --check, pyright clean.

#224 carries the same two-line change as its first commit (cherry-picked from #183). If this one lands first I drop that commit from #224; if #224 lands first this PR reduces to the test file and the CHANGELOG line.

The dependency constraint was protobuf>=5.29.4,<7, and the proto package
routed only major == 6 to the 6.x gencode, raising ValueError for
anything newer. An environment that already has protobuf 7 could not
resolve the SDK at all.

protobuf's runtime check (runtime_version.ValidateProtobufRuntimeVersion)
only rejects a runtime that is older than the gencode it loads, so the
6.x modules work unchanged on 7.x. Widen the constraint to <8 and route
every major >= 6 to the v6 modules. The full suite passes under both
protobuf 6.31.1 (867) and 7.36.2 (867) with no new warnings.

tests/proto_test.py reloads xai_sdk.proto under patched runtime versions:
7.0.0, 7.36.0 and 8.1.0 select v6 (fail on main), 6.x and 5.x keep their
modules, 4.x is still rejected.
@deanrie
deanrie requested a review from a team as a code owner October 23, 2026 17:59
@Omar-V2

Omar-V2 commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

This has been addressed by #223 and is fixed in versions 1.21.0 and above

@Omar-V2 Omar-V2 closed this Oct 23, 2026
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