Skip to content

fix: regenerate the stale avp_pb2 so import avp works with the protobuf 5.x runtime - #2

Open
LuMarans30 wants to merge 1 commit into
VectorArc:mainfrom
LuMarans30:fix/protobuf-gencode-runtime
Open

LuMarans30 wants to merge 1 commit into
VectorArc:mainfrom
LuMarans30:fix/protobuf-gencode-runtime

Conversation

@LuMarans30

@LuMarans30 LuMarans30 commented Sep 25, 2026 •

Copy link
Copy Markdown

Problem

import avp fails with a VersionError whenever the installed protobuf is
older than the linked gencode:

$ python -m venv /tmp/repro && . /tmp/repro/bin/activate
$ pip install -e ".[all]"
$ python -c "import avp"
google.protobuf.runtime_version.VersionError: Detected incompatible
Protobuf Gencode/Runtime versions when loading avp.proto:
gencode 6.31.1 runtime 5.29.6.

Root cause

pyproject.toml declared only protobuf>=4.21, while the checked-in
src/avp/avp_pb2.py was compiled with gencode 6.31.1, whose runtime guard
rejects any protobuf older than 6.31.1. So every environment constrained
below 6.31.1 failed at import avp. The all extra hits it deterministically
because autogen-core requires protobuf~=5.29.3, so pip install "avp[all]"
can never supply the runtime the stale gencode demands.

While regenerating, I also noticed the checked-in file had drifted from the
schema. It was last generated on 2026-03-24 (658aca2), right before 6f7d04e
removed EMBEDDING in v0.5.0. Since it was never recompiled,
avp_pb2.PayloadType still defined EMBEDDING = 2.

Fix

  • Recompiled src/avp/avp_pb2.py using protoc 5.29 (gencode 5.29.0).
  • Raised the minimum protobuf requirement from >=4.21 to >=5.29.
  • Pinned grpcio-tools to >=1.71.2,<1.72. grpcio-tools 1.72+ targets
    protobuf>=6.30 (1.84+ targets >=7.35.1), neither of which can coexist
    with autogen-core's pin (~=5.29.3). Left unpinned, the next make proto
    would reintroduce the mismatch and break installing dev alongside all.

proto/avp.proto is untouched. The only change in the generated code is
dropping the unused EMBEDDING value. The public PayloadType enum in
types.py never had it, so there are no public API changes.

Compatibility

  • The protobuf floor moves from >=4.21 to >=5.29: environments pinned to
    4.21-5.28 must upgrade. protobuf 4.x is end-of-life, and a 5.29-generated
    module cannot load on those runtimes.
  • No upper bound is needed: gencode 5.29 loads on newer runtimes too (verified
    on 7.36.1).
  • Peers on released 0.5.x/0.6.x still carry EMBEDDING = 2; codec.py already
    rejects unknown payload_type values, so decoding behavior is unchanged.

Verification

  • protobuf 5.29.6 and 7.36.1: import avp succeeds, avp_pb2.PayloadType
    contains only {HIDDEN_STATE, KV_CACHE}.
  • make proto with grpcio-tools==1.71.2 reproduces the committed file exactly
    (git diff clean).
  • tests/test_codec.py and tests/test_codec_v2.py pass (28 tests total).

…ads on the 5.x runtime

`src/avp/avp_pb2.py` was last regenerated on 2026-03-24 (`658aca2`), nine days
before `6f7d04e` removed `EMBEDDING` from `proto/avp.proto` and v0.5.0's
changelog announced it as "removed from SDK enum and proto schema". The
generated module was never regenerated, so the generated enum kept the value
even though the schema had dropped it: the checked-in copy still declares
`EMBEDDING = 2` in the `avp_pb2.PayloadType` descriptor. (The public
`avp.PayloadType` enum in `types.py` never carried it, so this changes no
public API.)

That stale copy was produced by protoc 6.31.1, whose guard refuses any runtime
older than the linked gencode:

    $ python -m venv /tmp/repro && . /tmp/repro/bin/activate
    $ pip install "protobuf==5.29.6"
    $ pip install -e .
    $ python -c "import avp"
    google.protobuf.runtime_version.VersionError: Detected incompatible
    Protobuf Gencode/Runtime versions when loading avp.proto:
    gencode 6.31.1 runtime 5.29.6.

The trigger is broader than any single extra: `pyproject.toml` declared only
`protobuf>=4.21`, so every environment constrained below 6.31.1 failed at
`import avp`. The `all` extra hits it deterministically because `autogen-core`
requires `protobuf~=5.29.3`, so `pip install "avp[all]"` can never supply a
runtime the stale gencode accepts.

Regenerate with protoc 5.29 (gencode 5.29.0) and raise the `protobuf` floor to
`>=5.29` to match. The floor bump is a deliberate narrowing: environments pinned
to protobuf 4.21-5.28 must upgrade, but protobuf 4.x is end-of-life and a
5.29-generated module cannot load on those runtimes. `grpcio-tools` is pinned to
`>=1.71.2,<1.72`; 1.72+ targets protobuf 6.30 and 1.84+ targets 7.35.1, neither
of which can coexist with `autogen-core`'s `~=5.29.3`. Left unpinned, the next
`make proto` would silently reintroduce the mismatch, and the `dev` and `all`
extras could no longer be co-installed.

`proto/avp.proto` is not touched. The only descriptor difference is the
disappearance of the dead `avp_pb2.PayloadType.EMBEDDING`, which nothing under
`src/` or `tests/` references.

Verified against protobuf 5.29.6 and 7.36.1: `import avp` succeeds and
`avp_pb2.PayloadType` exposes exactly `{HIDDEN_STATE, KV_CACHE}`. Regenerating
with the pinned toolchain reproduces the committed file exactly
(`grpcio-tools==1.71.2` + `make proto` leaves `git diff` clean), and
`tests/test_codec.py` + `tests/test_codec_v2.py` pass (28 tests).
@LuMarans30
LuMarans30 force-pushed the fix/protobuf-gencode-runtime branch from d43bb86 to 0ee71a2 Compare September 25, 2026 15:27

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.

1 participant