From d89f04a8496809b83748f63d33de2591899d9d22 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Baskaran Date: Sat, 2 May 2026 22:15:12 +0530 Subject: [PATCH] fix: replace deprecated FieldDescriptor.label with is_repeated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace all three uses of `field.label == FieldDescriptor.LABEL_REPEATED` with `field.is_repeated` in proto_utils.py, as tracked in #1011. The `FieldDescriptor.label` property was deprecated in protobuf 4.x. Since the minimum protobuf requirement is already >=5.29.5 (where `is_repeated` is available), this cleanup is safe to apply now. Affected functions: - `parse_params()` — REST query parameter parsing - `_check_required_field_violation()` — required field validation - `_recurse_validation()` — nested message recursion Closes #1011 --- src/a2a/utils/proto_utils.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/a2a/utils/proto_utils.py b/src/a2a/utils/proto_utils.py index b191f98e0..e6f623ff7 100644 --- a/src/a2a/utils/proto_utils.py +++ b/src/a2a/utils/proto_utils.py @@ -174,10 +174,7 @@ def parse_params(params: QueryParams, message: ProtobufMessage) -> None: field = fields[k] v_list = params.getlist(k) - # TODO(https://github.com/a2aproject/a2a-python/issues/1011): Replace - # deprecated `field.label` with `field.is_repeated` once the minimum - # protobuf version requirement is bumped. - if field.label == FieldDescriptor.LABEL_REPEATED: + if field.is_repeated: accumulated: list[Any] = [] for v in v_list: if not v: @@ -211,10 +208,7 @@ def _check_required_field_violation( ) -> ValidationDetail | None: """Check if a required field is missing or invalid.""" val = getattr(msg, field.name) - # TODO(https://github.com/a2aproject/a2a-python/issues/1011): Replace - # deprecated `field.label` with `field.is_repeated` once the minimum - # protobuf version requirement is bumped. - if field.label == FieldDescriptor.LABEL_REPEATED: + if field.is_repeated: if not val: return ValidationDetail( field=field.name, @@ -255,10 +249,7 @@ def _recurse_validation( return errors val = getattr(msg, field.name) - # TODO(https://github.com/a2aproject/a2a-python/issues/1011): Replace - # deprecated `field.label` with `field.is_repeated` once the minimum - # protobuf version requirement is bumped. - if field.label != FieldDescriptor.LABEL_REPEATED: + if not field.is_repeated: if msg.HasField(field.name): sub_errs = _validate_proto_required_fields_internal(val) _append_nested_errors(errors, field.name, sub_errs)