Skip to content

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

Closed

Description

@sokoliva

Summary

src/a2a/utils/proto_utils.py currently uses the deprecated FieldDescriptor.label property to check whether a protobuf field is repeated. The non-deprecated alternative is FieldDescriptor.is_repeated, but adopting it requires a newer minimum version of protobuf than we currently declare, which would be a breaking change for downstream consumers.

Locations

All occurrences are in src/a2a/utils/proto_utils.py:

  • src/a2a/utils/proto_utils.py:177 — _populate_message_from_params (or similar)
  • src/a2a/utils/proto_utils.py:211 — _check_required_field_violation
  • src/a2a/utils/proto_utils.py:252 — _recurse_validation
    Each site is marked with a TODO comment referencing this issue.

Proposed change

  1. Bump the minimum required protobuf version in pyproject.toml to one that exposes FieldDescriptor.is_repeated as a stable, non-deprecated API.
  2. Replace all field.label == FieldDescriptor.LABEL_REPEATED checks with field.is_repeated.
  3. Replace all field.label != FieldDescriptor.LABEL_REPEATED checks with not field.is_repeated.
  4. Remove the TODO comments and unused LABEL_REPEATED import if no longer needed.
  5. Schedule the change as part of the next breaking release.

Activity

  1. liujuanjuan1984 commented on Apr 27, 2026

    @liujuanjuan1984
    Contributor

    We hit this in downstream integration with a2a-sdk==1.0.2 on a real server path.

    Concrete repro:

    • a2a-sdk==1.0.2
    • protobuf==7.34.1
    • call path: DefaultRequestHandler.on_get_task() -> @validate_request_params -> validate_proto_required_fields() -> _check_required_field_violation()
    • runtime error: AttributeError: 'google._upb._message.FieldDescriptor' object has no attribute 'label'

    A few details from our side:

    • a2a-sdk 1.0.2 currently declares Requires-Dist: protobuf>=5.29.5, so a normal resolver can select 7.x
    • with protobuf 5.29.5 and 6.33.5, field.label is still present
    • with protobuf 7.34.1, field.label is absent while field.is_repeated exists
    • pinning downstream to protobuf<7 immediately resolves the crash

    So the current field.label implementation is not compatible with all versions allowed by the published dependency range.

    Given PR #1010 and the direction in this issue, I think there are two viable fixes:

    1. short-term: tighten packaging to protobuf<7
    2. follow-up: add a compatibility branch in proto_utils that prefers field.is_repeated when available and falls back to field.label

    If useful, I can also open a PR for the packaging bound change.

  2. added a commit that references this issue on Apr 27, 2026
  3. added 2 commits that reference this issue on May 5, 2026
    f88baa2
    69a8139
  4. added theissue type on May 15, 2026
  5. piyushbag commented on Jul 21, 2026

    @piyushbag

    Planning to open a PR for backward-compatible repeated-field detection in proto_utils (prefer field.is_repeated, fall back to field.label on older protobuf runtimes). Will include tests covering both code paths.

  6. djanito commented on Aug 20, 2026

    @djanito

    Any news on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions