[Bug]: ListTasksResult rejects valid responses when pageSize ≠ number of returned tasks (InvalidParamsError)
Les mainteneurs répondent en général sous 1 jour
Une pull request liée a déjà été fusionnée.
- #1273 par @RaphaelFakhri — fusionnée
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 25/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- Java
- Étoiles
- 510
- Forks
- 196
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 57
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de a2aproject/a2a-java
-
HTTP+JSON CancelTask returns 409 Conflict instead of 400 Bad Request for TaskNotCancelableErrorOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
a2aproject/a2a-java#1298 ·
Les mainteneurs répondent en général sous 1 jour
-
fix: handle blank push notification config id consistently across transportsPeut-être pris @prachisinghal-1 l’a pris il y a 15 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
a2aproject/a2a-java#1012 · 2 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
a2aproject/a2a-java#464 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Create a sample that demonstrates how to use a shared contextId across multiple tasksPeut-être à nouveau libre @tanish111 l’a pris il y a 381 jours, et aucune pull request n’est ouverte. Ouvertesample
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
a2aproject/a2a-java#375 · 5 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 30/100
a2aproject/a2a-java#1299 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de a2aproject/a2a-java
Issues similaires
-
bug web-ui
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
jenkinsci/jenkins#27705 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
googleads/googleads-mobile-flutter#1541 ·
Les mainteneurs répondent en général sous 4 jours
-
Keyboard crashes Chrome tabsOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
Julow/Unexpected-Keyboard#1490 ·
Les mainteneurs répondent en général sous 4 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
Vakore/ZappierGames#275 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
unitycatalog/unitycatalog#2148 ·
Les mainteneurs répondent en général sous 2 jours