a2aproject / a2aproject/a2a-python

[Bug]: Response Stream Array-Wrapping Crash (Transport Layer Mismatch)

Đang mở
#1,089 6 bình luận 0 reaction 1 người được giao Được @ishymko nhận Xem trên GitHub
component: client
Ngôn ngữ chính
Python
Star
2.1k
Fork
496
Merge trung bình
4 ngày 17 giờ
Pull request đã merge (30 ngày)
12

Mô tả

### What happened?

This is continuation from #1074 as splitting into two issues are suggested by @ishymko

Copied the issue description below for context

##### Response Stream Array-Wrapping Crash (Transport Layer Mismatch)
By default, Google wraps streaming RPC responses (`Flow`) inside a JSON array `[ {"task": ...} ]` to frame stream chunk boundaries on the wire.
* **The Mismatch**: The SDK's legacy compatibility transport (`CompatRestTransport` inside `a2a/compat/v0_3/rest_transport.py`) fails to request standard SSE transcoding from Google because it does not append the standard **`?alt=sse`** query parameter to the stream endpoint URL. This forces Google to fall back to default plain JSON array-wrapped streams.
* **The Crash**: Standard transports in `a2a/client/transports/rest.py` parse stream events using standard `Parse` (from `google.protobuf.json_format`):
```python
event: StreamResponse = Parse(sse_data, StreamResponse())
```
Because standard `Parse` strictly expects a single JSON object `{...}`, the leading and trailing array brackets (`[` and `]`) cause `json_format.Parse` to crash immediately on the very first chunk:
```python
google.protobuf.json_format.ParseError: Failed to parse {'task': {...}} field: unhashable type: 'dict'.
```

----

Thanks for pointing this issue is not specific to v0.3 but v1 as well. Regarding the workaround mentioned in https://github.com/a2aproject/a2a-python/issues/1074#issuecomment-4555290758 , yes it will work with the workaround but this mean all the customer/developer who integrated with Google A2A APIs will require this workaround introduces developer friction. Is there any way we could make this smoother so developer can use SDK with Google A2A API out of the box? Thanks!

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.