Skip to content

fix(proto-utils): use FieldDescriptor.is_repeated instead of removed .label#1042

Open
sonirico wants to merge 2 commits intoa2aproject:mainfrom
sonirico:fix/field-label-removed
Open

fix(proto-utils): use FieldDescriptor.is_repeated instead of removed .label#1042
sonirico wants to merge 2 commits intoa2aproject:mainfrom
sonirico:fix/field-label-removed

Conversation

@sonirico
Copy link
Copy Markdown

@sonirico sonirico commented May 3, 2026

Summary

Three call sites in proto_utils.py use FieldDescriptor.label, which protobuf 7.x removed from both the upb and pure-Python backends. Every JSON-RPC method that runs through the request handler raises AttributeError before the agent executor is ever called:

File "a2a/utils/proto_utils.py", line 217, in _check_required_field_violation
    if field.label == FieldDescriptor.LABEL_REPEATED:
AttributeError: 'FieldDescriptor' object has no attribute 'label'

The code already had TODOs referencing #1011 with the exact intended fix ("Replace deprecated field.label with field.is_repeated once the minimum protobuf version requirement is bumped"). Since the package's protobuf>=5.29.5 floor is well past the version that supports is_repeated, we can land the swap now.

Changes

  • parse_query_params_to_proto (was line 180): body request parsing
  • _check_required_field_violation (was line 217): required-field validator
  • _recurse_validation (was line 261): nested-message validator

Each field.label == FieldDescriptor.LABEL_REPEATED becomes field.is_repeated, and the inverse != becomes not field.is_repeated. The corresponding TODO comments are removed.

Test plan

  • Confirmed locally that validate_proto_required_fields fails on protobuf 7.34.1 against a2a-sdk==1.0.2 without the patch
  • Confirmed integration into a downstream FastAPI server (Pictomancer.ai gateway, JSON-RPC endpoint) works end-to-end after applying the patch — message/send, tasks/get, agent/getAuthenticatedExtendedCard all return correctly
  • CI here will run the existing tests/utils/test_proto_utils.py and tests/compat/v0_3/test_proto_utils.py suites, which should still pass (the change is semantically equivalent on protobuf versions that have both attributes)

Closes #1011

….label

protobuf 7.x dropped FieldDescriptor.label from both upb and pure-Python
backends, breaking all three call sites in proto_utils.py at runtime:

  AttributeError: 'FieldDescriptor' object has no attribute 'label'

The code already had TODO comments referencing a2aproject#1011 with the exact
intended fix ("Replace deprecated `field.label` with `field.is_repeated`
once the minimum protobuf version requirement is bumped"). Since the
package's protobuf>=5.29.5 floor is well past the version that exposed
both attributes, we can land the swap now.

Three call sites:
  - parse_query_params_to_proto (line 180): body request parsing
  - _check_required_field_violation (line 217): required-field validator
  - _recurse_validation (line 261): nested-message validator

Without this fix, every JSON-RPC method that runs through the request
handler raises AttributeError before the agent executor is ever called.

Closes a2aproject#1011
@sonirico sonirico requested a review from a team as a code owner May 3, 2026 13:02
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 by replacing the deprecated field.label attribute with the field.is_repeated property across several functions, including parse_params, _check_required_field_violation, and _recurse_validation. These changes resolve existing TODOs and align the code with modern protobuf standards. I have no feedback to provide.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

🧪 Code Coverage (vs main)

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

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.

[Task]: Replace deprecated FieldDescriptor.label with is_repeated in proto_utils

1 participant