Skip to content

Commit 6b3f04f

Browse files
committed
test: Add numeric string roundtrip test and fix mypy type error
- Add test case for numeric strings (e.g., zip codes, numeric IDs) in metadata edge cases - Fix mypy type error in _convert_value_to_proto for null_value assignment - Use proper struct_pb2.NullValue.NULL_VALUE instead of integer 0 - Ensure numeric strings remain as strings after roundtrip conversion
1 parent 33318f5 commit 6b3f04f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/a2a/utils/proto_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _make_dict_serializable(cls, value: Any) -> Any:
7171
def _convert_value_to_proto(cls, value: Any) -> struct_pb2.Value:
7272
if value is None:
7373
proto_value = struct_pb2.Value()
74-
proto_value.null_value = 0
74+
proto_value.null_value = struct_pb2.NullValue.NULL_VALUE
7575
return proto_value
7676

7777
if isinstance(value, bool):

tests/utils/test_proto_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ def test_metadata_edge_cases(self):
342342
'large_number': 9999999999999999,
343343
'negative_number': -42,
344344
'float_precision': 0.123456789,
345+
'numeric_string': '12345',
345346
}
346347

347348
# Convert to proto and back
@@ -358,3 +359,4 @@ def test_metadata_edge_cases(self):
358359
assert roundtrip_metadata['large_number'] == 9999999999999999
359360
assert roundtrip_metadata['negative_number'] == -42
360361
assert abs(roundtrip_metadata['float_precision'] - 0.123456789) < 1e-10
362+
assert roundtrip_metadata['numeric_string'] == '12345'

0 commit comments

Comments
 (0)