Skip to content

Commit 1196db8

Browse files
committed
fix the handling of unknown part types
1 parent 18ce0c4 commit 1196db8

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/a2a/contrib/tasks/vertex_task_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def to_sdk_part(stored_part: vertexai_types.Part) -> Part:
107107
)
108108
)
109109

110-
return Part(root=TextPart(text=''))
110+
raise ValueError(f"Unsupported part: {stored_part}")
111111

112112

113113
def to_stored_artifact(artifact: Artifact) -> vertexai_types.TaskArtifact:

tests/contrib/tasks/test_vertex_task_converter.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import base64
2-
import json
32

43
import pytest
54

5+
66
pytest.importorskip(
77
'vertexai', reason='Vertex Task Converter tests require vertexai'
88
)
@@ -190,11 +190,10 @@ def test_to_sdk_part_file_data() -> None:
190190
assert sdk_part.root.file.uri == 'gs://bucket/image.jpg'
191191

192192

193-
def test_to_sdk_part_empty() -> None:
193+
def test_to_sdk_part_unsupported() -> None:
194194
stored_part = vertexai_types.Part()
195-
sdk_part = to_sdk_part(stored_part)
196-
assert isinstance(sdk_part.root, TextPart)
197-
assert sdk_part.root.text == ''
195+
with pytest.raises(ValueError, match='Unsupported part:'):
196+
to_sdk_part(stored_part)
198197

199198

200199
def test_to_stored_artifact() -> None:

0 commit comments

Comments
 (0)