Commit 7d197db
authored
fix(proto): use field.label instead of is_repeated for protobuf compatibility (#1010)
# 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](https://github.com/protocolbuffers/protobuf/releases/tag/v34.0-rc1.1),
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.1 parent b3d1ad6 commit 7d197db
1 file changed
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
178 | 181 | | |
179 | 182 | | |
180 | 183 | | |
| |||
208 | 211 | | |
209 | 212 | | |
210 | 213 | | |
211 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
212 | 218 | | |
213 | 219 | | |
214 | 220 | | |
| |||
249 | 255 | | |
250 | 256 | | |
251 | 257 | | |
252 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
253 | 262 | | |
254 | 263 | | |
255 | 264 | | |
| |||
0 commit comments