[Bug]: ListTasksResult rejects valid responses when pageSize ≠ number of returned tasks (InvalidParamsError)

Offen
#1,260 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@RaphaelFakhri arbeitet bereits daran.

Seit 02.11.2026.

  • #1273 von @RaphaelFakhri — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
25/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
java, json
Bereich
api

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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
  1. Run an A2A server whose ListTasks response returns the requested page size in pageSize. The Python a2a-sdk 1.1.2 InMemoryTaskStore and DatabaseTaskStore do this (page_size = params.page_size or 50, returned as-is).
  2. Create 2 tasks in one contextId.
  3. 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. Keep pageSize >= 0 if wanted.
  • Optionally, if the intent really is "count returned", the spec wording for the response pageSize should 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
Vorherrschende Sprache
Java
Sterne
510
Forks
196
Ø Merge
2 T. 22 Std.
Gemergte PRs (30 T.)
31

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus a2aproject/a2a-java

Alle Issues in a2aproject/a2a-java

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.