[Bug]: ListTasksResult rejects valid responses when pageSize ≠ number of returned tasks (InvalidParamsError)
维护者通常 1 天内回复
已经有一个关联 PR 被合并了。
- #1273 来自 @RaphaelFakhri —— 已合并
评估
调研方向
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 天 9 小时
- 30 天内合并 PR
- 50
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
a2aproject/a2a-java 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
a2aproject/a2a-java#1275 · 2 条评论 ·
维护者通常 1 天内回复
-
fix: handle blank push notification config id consistently across transports可能已有人在做 @prachisinghal-1 于 12 天前认领。 未关闭
难度 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 于 379 天前认领,目前没有进行中的 PR。 未关闭sample
难度 2/5 1-3 小时 新手友好度 70/100
a2aproject/a2a-java#375 · 5 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Task state transitions are not tracked可能重新可做 @sumitvairagar 于 18 天前认领,目前没有进行中的 PR。 未关闭
难度 3/5 1-2 天 新手友好度 45/100
a2aproject/a2a-java#1222 · 4 条评论 ·
维护者通常 1 天内回复
查看 a2aproject/a2a-java 的全部 Issue
相似的 Issue
-
needs-area-label
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 2 天内回复
-
enhancement Java macOS
难度 2/5 1-3 小时 新手友好度 78/100
freerouting/freerouting#1079 ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
apache/maven-enforcer#1074 ·
维护者通常 1 天内回复
-
Gradle liquibaseDiffChangelog drops jhi_date_time_wrapper可能已有人在做 @mraible 今天认领。 未关闭area: triage theme: undefined
难度 2/5 1-3 小时 新手友好度 88/100
jhipster/generator-jhipster#35998 ·
维护者通常 1 天内回复