[Bug]: ListTasksResult rejects valid responses when pageSize ≠ number of returned tasks (InvalidParamsError)
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
The strict check is in the compact constructor of jsonrpc-common/src/main/java/org/a2aproject/sdk/jsonrpc/common/wrappers/ListTasksResult.java; the error surfaces through ProtoUtils.FromProto.convert in the grpc utils. Pull request #1273 is already open against this issue, so review or build on that work rather than starting a parallel fix. Done means a response with pageSize 50 and 2 tasks parses into a ListTasksResult, with a test covering that case.
索引モデルが issue の本文から書いたものです。
説明
What happened?
Component: jsonrpc-common (ListTasksResult), reached via the JSON-RPC client transport
Version: a2a-java-sdk-client 1.4.0.Final (JSON-RPC transport)
What happened
Client.listTasks(...) fails with InvalidParamsError whenever the server's response has a pageSize that differs from the number of tasks in tasks. In practice this is every page that isn't completely full.
org.a2aproject.sdk.spec.InvalidParamsError: pageSize must be equal to the number of tasks in the list. Got 50, but list has 2 tasks.
at org.a2aproject.sdk.grpc.utils.ProtoUtils$FromProto.convert(ProtoUtils.java:200)
at org.a2aproject.sdk.grpc.utils.ProtoUtils$FromProto.listTasksResult(ProtoUtils.java:344)
at org.a2aproject.sdk.grpc.utils.JSONRPCUtils.parseResponseBody(JSONRPCUtils.java:325)
at org.a2aproject.sdk.client.transport.jsonrpc.JSONRPCTransport.unmarshalResponse(JSONRPCTransport.java:369)
at org.a2aproject.sdk.client.transport.jsonrpc.JSONRPCTransport.listTasks(JSONRPCTransport.java:181)
at org.a2aproject.sdk.client.Client.listTasks(Client.java:408)
at org.a2aproject.sdk.client.AbstractClient.listTasks(AbstractClient.java:213)
Steps to reproduce
- Run an A2A server whose
ListTasksresponse returns the requested page size inpageSize. The Pythona2a-sdk1.1.2InMemoryTaskStoreandDatabaseTaskStoredo this (page_size = params.page_size or 50, returned as-is). - Create 2 tasks in one
contextId. - Call
client.listTasks(ListTasksParams.builder().contextId(ctx).pageSize(50).build()).
The server responds with this (abridged):
{"jsonrpc":"2.0","id":"1","result":{"tasks":[{...},{...}],"nextPageToken":"","pageSize":50,"totalSize":2}}
Expected behaviour
The response parses into a ListTasksResult with 2 tasks.
Actual behaviour
InvalidParamsError, thrown from the ListTasksResult compact constructor:
if (pageSize != tasks.size()) {
throw new IllegalArgumentException("pageSize must be equal to the number of tasks in the list. Got " + pageSize + ", but list has " + tasks.size() + " tasks.");
}
(jsonrpc-common/src/main/java/org/a2aproject/sdk/jsonrpc/common/wrappers/ListTasksResult.java)
Why this looks like an SDK bug
The A2A specification, §3.1.4 List Tasks, says:
- Request
pageSize: "The maximum number of tasks to return. The service may return fewer than this value." - Response
pageSize: "The page size used for this response."
A server may therefore return fewer tasks than pageSize, and the response pageSize is the page size applied rather than the count of tasks returned. The strict equality check rejects responses the spec allows.
Suggested fix
- Remove the
pageSize != tasks.size()check. KeeppageSize >= 0if wanted. - Optionally, if the intent really is "count returned", the spec wording for the response
pageSizeshould be clarified. Either way the SDK and the spec should agree.
Workaround
I currently rewrite result.pageSize to tasks.length in a decorating A2AHttpClient before the SDK parses the response.
Relevant log output
org.a2aproject.sdk.spec.InvalidParamsError: pageSize must be equal to the number of tasks in the list. Got 50, but list has 2 tasks.
at org.a2aproject.sdk.grpc.utils.ProtoUtils$FromProto.convert(ProtoUtils.java:200)
at org.a2aproject.sdk.grpc.utils.ProtoUtils$FromProto.listTasksResult(ProtoUtils.java:344)
at org.a2aproject.sdk.grpc.utils.JSONRPCUtils.parseResponseBody(JSONRPCUtils.java:325)
at org.a2aproject.sdk.client.transport.jsonrpc.JSONRPCTransport.unmarshalResponse(JSONRPCTransport.java:369)
at org.a2aproject.sdk.client.transport.jsonrpc.JSONRPCTransport.listTasks(JSONRPCTransport.java:181)
at org.a2aproject.sdk.client.Client.listTasks(Client.java:408)
at org.a2aproject.sdk.client.AbstractClient.listTasks(AbstractClient.java:213)
Code of Conduct
- I agree to follow this project's Code of Conduct
- 主要言語
- Java
- スター
- 510
- フォーク
- 196
- 平均マージ
- 2日 22時間
- マージ済み PR(30日)
- 31
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
a2aproject/a2a-java のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
a2aproject/a2a-java#1275 ·
メンテナーはふだん 1 日以内に返信
-
fix: handle blank push notification config id consistently across transports対応中かも @prachisinghal-1 が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
a2aproject/a2a-java#1012 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
a2aproject/a2a-java#464 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Create a sample that demonstrates how to use a shared contextId across multiple tasks再び着手できるかも @tanish111 が 378 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンsample
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
a2aproject/a2a-java#375 · コメント 5 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Task state transitions are not tracked再び着手できるかも @sumitvairagar が 17 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
a2aproject/a2a-java#1222 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
a2aproject/a2a-java の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Dans-Plugins/Medieval-Roleplay-Engine#396 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
LtByXsl throws NoSuchElementException when defect element has no text content対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
objectionary/lints#1640 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
virtualcell/vcell#2193 ·
メンテナーはふだん 1 日以内に返信