[Bug]: v0.3 SendMessage returns Internal error instead of InvalidParams for a missing messageId or empty parts

Đang mở
#1,336 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@cchinchilla-dev đang làm issue này rồi.

Từ ngày 15/11/2026.

  • #1337 của @cchinchilla-dev — đang mở

Đánh giá

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

Hướng nghiên cứu

Read Convert_v0_3_To10RequestHandler and ProtoUtils_v0_3.FromProto, focusing on the message send paths named in the issue. Compare how v1.0 converts these validation exceptions to invalid-params errors. The issue says a fix is already being opened in linked PR #1337, so check that work before taking this on.

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

Mô tả

What happened?

In the v0.3 compatibility layer, a SendMessage whose message has no messageId or an empty parts list is only rejected with InvalidParamsError by JSON-RPC message/send. REST and gRPC report it as an internal error (HTTP 500 and INTERNAL), and so does JSON-RPC message/stream when messageId is missing.

Both checks throw IllegalArgumentException from a record constructor:

  • messageId: Message_v0_3 accepts a null messageId, but the v1.0 Message it is converted to in MessageSendParamsMapper_v0_3.toV10 (called from Convert_v0_3_To10RequestHandler.onMessageSend and onMessageSendStream) throws Parameter 'messageId' may not be null.
  • parts: on REST and gRPC, ProtoUtils_v0_3.FromProto.message builds a Message_v0_3, which throws Parts cannot be empty.

Only JSONRPCHandler_v0_3.onMessageSend maps that exception to InvalidParamsError_v0_3:

} catch (IllegalArgumentException t) {
    return new SendMessageResponse_v0_3(request.getId(), new InvalidParamsError_v0_3(t.getMessage()));
}

Everywhere else it reaches catch (Throwable) and is reported as InternalError_v0_3. The v1.0 side does not have this problem, because ProtoUtils.FromProto.convert() turns the same exception into InvalidParamsError where it is raised.

Against the compat-0.3/tck server on main:

$ curl -s -w ' [%{http_code}]' localhost:9999/v1/message:send -H 'Content-Type: application/json' \
    -d '{"message":{"role":"ROLE_USER","content":[{"text":"x"}]}}'
{"error": "org.a2aproject.sdk.compat03.spec.InternalError_v0_3", "message": "Internal error"} [500]

$ curl -s -w ' [%{http_code}]' localhost:9999/v1/message:send -H 'Content-Type: application/json' \
    -d '{"message":{"messageId":"m-1","role":"ROLE_USER","content":[]}}'
{"error": "org.a2aproject.sdk.compat03.spec.InternalError_v0_3", "message": "Internal error"} [500]

The v0.3 TCK reports this for REST and gRPC in the tck-test-0-3 job of the Run TCK workflow on main: test_missing_required_message_fields (Expected InvalidParams error code -32602 for missing messageId, but got: -32603) and test_empty_arrays. The JSON-RPC streaming case is not covered by the TCK.

Expected: InvalidParamsError_v0_3 on every transport, as JSON-RPC message/send returns.
Actual: InternalError_v0_3 (HTTP 500 for REST message:send, an InternalError_v0_3 event for message:stream, INTERNAL over gRPC, -32603 for JSON-RPC message/stream).

Suggested fix: convert the IllegalArgumentException to an invalid params error where it is raised, as v1.0 does: around MessageSendParamsMapper_v0_3.INSTANCE.toV10(...) in Convert_v0_3_To10RequestHandler, and in ProtoUtils_v0_3.FromProto.messageSendParams. That covers the three transports without catching unrelated exceptions in the handlers.

I have a fix ready and I'm opening a PR alongside this issue.

Code of Conduct
  • I agree to follow this project's Code of Conduct
Ngôn ngữ chính
Java
Star
514
Fork
200
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
53

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của a2aproject/a2a-java

Tất cả issue của a2aproject/a2a-java

Issue tương tự

Thêm issue về Java

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.