Skip to content

fix(proto): use field.label instead of is_repeated for protobuf compatibility#1010

Merged
sokoliva merged 4 commits intoa2aproject:mainfrom
sokoliva:protobuf-version
Apr 22, 2026
Merged

fix(proto): use field.label instead of is_repeated for protobuf compatibility#1010
sokoliva merged 4 commits intoa2aproject:mainfrom
sokoliva:protobuf-version

Conversation

@sokoliva
Copy link
Copy Markdown
Member

@sokoliva sokoliva commented Apr 22, 2026

Description

Replace field.is_repeated with field.label == field.LABEL_REPEATED in proto_utils.py to support older protobuf versions where the is_repeated attribute is not available on FieldDescriptor.

Problem

When using older protobuf versions accessing field.is_repeated raises:
a2a.utils.errors.InternalError: 'google._upb._message.FieldDescriptor' object has no attribute 'is_repeated'
The project's declared minimum is protobuf>=5.29.5, 5.29.5 does not support is_repeated. This caused send_message (and other proto-validating client calls) to fail at runtime for users on older protobuf releases.
The is_repeated property was only added to FieldDescriptor in newer protobuf releases (6.x), so relying on it broke compatibility with the supported version range.

Although the deprecated label was already removed in some 7.x version, 7.x version can't be resolved with the other constraints we have in the project.

Fix

Use the long-standing label attribute and compare against FieldDescriptor.LABEL_REPEATED, which is available across all supported protobuf versions and is the canonical way to detect repeated fields.

Testing

  • uv run pytest passes against the supported protobuf version range.

@sokoliva sokoliva requested a review from a team as a code owner April 22, 2026 13:35
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

🧪 Code Coverage (vs main)

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates src/a2a/utils/proto_utils.py to replace the use of the is_repeated property with explicit checks against the LABEL_REPEATED constant. The reviewer suggests accessing these constants via the FieldDescriptor class rather than the field instance to ensure idiomatic consistency and better compatibility with various protobuf backends.

Comment thread src/a2a/utils/proto_utils.py Outdated
Comment thread src/a2a/utils/proto_utils.py Outdated
Copy link
Copy Markdown
Member

@ishymko ishymko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description nit:

-protobuf>=5.29.0,
+protobuf>=5.29.5,

Comment thread src/a2a/utils/proto_utils.py Outdated
Comment thread src/a2a/utils/proto_utils.py Outdated
Copy link
Copy Markdown
Member

@ishymko ishymko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also mention in the description that although the deprecated label was already removed in some 7.x version, 7.x version can't be resolved with the other constraints we have in the project.

@sokoliva sokoliva merged commit 7d197db into a2aproject:main Apr 22, 2026
35 checks passed
@sokoliva sokoliva deleted the protobuf-version branch April 22, 2026 13:58
ishymko pushed a commit that referenced this pull request Apr 24, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.0.2](v1.0.1...v1.0.2)
(2026-04-24)


### Features

* **helpers:** add non-text Part, Message, and Artifact helpers
([#1004](#1004))
([cfdbe4c](cfdbe4c))


### Bug Fixes

* **proto:** use field.label instead of is_repeated for protobuf
compatibility
([#1010](#1010))
([7d197db](7d197db))
* **server:** deliver push notifications across all owners
([#1016](#1016))
([c24ae05](c24ae05))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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