a2aproject / a2aproject/a2a-js

[Bug]: JSON-RPC SSE error events lose their typed A2A error

Đang mở
#712 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
613
Fork
169
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
21

Mô tả

## What happened

The JSON-RPC client maps an error response from a unary request to a typed A2A error, but wraps the same error envelope from an SSE stream in a generic `Error`.

For example, JSON-RPC error code `-32001` is exposed as `TaskNotFoundError` by `SendMessage`. When it arrives as an SSE error event from `SendStreamingMessage`, the caught error instead has `name === "Error"` and fails `instanceof JsonRpcTaskNotFoundError`; the typed error is only available through `error.cause`.

## What I expected

The same JSON-RPC error envelope should produce the same typed A2A error regardless of whether it arrives through a unary response or an SSE error event. Callers should be able to use the SDK's error classes consistently for branching, retries, and recovery.

## Steps to reproduce

1. Create a `JsonRpcTransport` with a fetch implementation that returns HTTP 200 and `Content-Type: text/event-stream`.
2. Return an SSE error event whose data is a matching JSON-RPC response with error code `-32001` and message `"Task not found"`.
3. Iterate `sendMessageStream()` and catch the thrown error.
4. Observe that the error is a generic `Error`; its `cause` is the typed `TaskNotFoundError`.
5. Return the same JSON-RPC error envelope from `sendMessage()` and observe that the typed error is thrown directly.

## Additional context

Minimal comparison:

```text
unary: name=TaskNotFoundError, typed=true
streaming: name=Error, typed=false, cause=TaskNotFoundError
```

This makes streaming and non-streaming calls expose different public error contracts for the same protocol failure. Mapping and throwing the SSE error envelope directly would preserve the semantic and JSON-RPC-specific error information.

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

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

Hướng nghiên cứu

Look at the JSON-RPC client code, likely in a transport or client module, to see how unary errors are mapped to typed A2A errors (like TaskNotFoundError). Then find the SSE stream handling, likely in a streaming transport or event source adapter, to see where error events are parsed and thrown. Compare the two error-wrapping paths. The fix is to ensure the SSE error envelope is mapped to the same typed error class before being thrown. Test by running the provided reproduction steps, checking the error's name and instanceof behavior.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, typescript
Lĩnh vực
api, backend-api-design
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
65/100

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.