Skip to content

Conversation

@kabir
Copy link
Collaborator

@kabir kabir commented Nov 13, 2025

These fixes are needed for the TCK tests in a2aproject/a2a-tck#93

  • Add includingDefaultValueFields() to prevent missing fields in JSON responses
  • Fix parameter validation: enum UNRECOGNIZED, negative timestamps, zeroToNull
  • REST: accept multiple timestamp/status formats and add validation
  • JSON-RPC: add "Invalid enum value:" pattern for -32602 error code

@kabir kabir marked this pull request as draft November 13, 2025 15:20
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kabir, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses necessary changes to enable the successful execution of new TCK tests for the tasks/list endpoint. The core of these changes involves a significant overhaul of the task listing and pagination mechanism, moving from a simple ID-based cursor to a more robust keyset pagination approach utilizing task timestamps. Additionally, a new lastUpdatedAfter filter has been introduced to enhance query capabilities. These updates ensure compliance with the latest specification requirements, including a temporary protobuf schema divergence to align with an anticipated upstream change.

Highlights

  • Enhanced Task Listing Pagination: Implemented keyset pagination for ListTasks endpoints, sorting tasks by statusTimestamp (descending) and then id (ascending) for consistent and efficient retrieval. This replaces the previous ID-based cursor pagination.
  • New lastUpdatedAfter Filter: Added a new parameter to the ListTasks API to filter tasks based on their statusTimestamp, allowing retrieval of tasks updated after a specific point in time. This includes validation to prevent future timestamps.
  • Page Token Format Update: The pageToken now uses a composite format of 'timestamp_millis:taskId' to support keyset pagination, with robust validation for correct format and error handling for malformed tokens.
  • Denormalized statusTimestamp: Introduced a statusTimestamp field in JpaTask to denormalize the task's last update timestamp, enabling efficient database indexing and querying for the new sorting and filtering mechanisms.
  • Improved History Limiting Logic: Refined the historyLength parameter logic to explicitly handle historyLength=0 by returning an empty history list, ensuring clearer behavior.
  • Protobuf Schema Alignment: Updated the ListTasksResponse protobuf definition to include a page_size field and reordered total_size to align with an upcoming upstream PR (#1160). A PROTO_DIVERGENCE.md file has been added to document this temporary divergence.
  • Comprehensive Test Coverage: Added new unit tests to JpaDatabaseTaskStoreTest to validate the new keyset pagination logic, including scenarios with different timestamps and invalid page token formats, ensuring robustness.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces significant changes to the task listing functionality to align with new TCK tests. The key changes include implementing keyset pagination based on a composite sort key (timestamp and ID), adding a lastUpdatedAfter filter, and ensuring consistent behavior across both JPA and in-memory task stores. The protobuf specification has also been updated to include pageSize in the ListTasksResponse.

The changes are well-tested, with new unit tests covering the new pagination and filtering logic. My review focuses on improving code maintainability by reducing duplication, fixing a potential null pointer exception in the in-memory implementation, and removing temporary debug logging.

@fjuma
Copy link
Collaborator

fjuma commented Nov 24, 2025

This one now has some conflicts.

@kabir kabir changed the title fix: Changes needed to get the new TCK tests for tasks/list to pass fix: ListTasks validation and serialization across all transports Jan 15, 2026
@kabir kabir marked this pull request as ready for review January 15, 2026 17:32
@kabir
Copy link
Collaborator Author

kabir commented Jan 15, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces several important fixes and improvements related to validation and serialization for ListTasks functionality across gRPC, JSON-RPC, and REST transports. Key changes include correctly handling historyLength = 0 to return an empty history list, enhanced parameter validation for pageSize, historyLength, lastUpdatedAfter (negative timestamps), and TaskState (unrecognized enum values). The REST API now offers greater flexibility by accepting multiple formats for status and lastUpdatedAfter. Crucially, includingDefaultValueFields() is now used in JSON-RPC and REST responses to ensure that fields with default values are always present in the JSON output, which is vital for client-side parsing. Comprehensive unit tests have been added to cover these new behaviors, significantly improving the robustness, usability, and correctness of the ListTasks API across all transports.

Comment on lines +46 to +57

// Validate pageSize (1-100)
if (pageSize != null && (pageSize < 1 || pageSize > 100)) {
throw new InvalidParamsError(null,
"pageSize must be between 1 and 100, got: " + pageSize, null);
}

// Validate historyLength (>= 0)
if (historyLength != null && historyLength < 0) {
throw new InvalidParamsError(null,
"historyLength must be non-negative, got: " + historyLength, null);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Adding validation for pageSize (1-100) and historyLength (non-negative) in the compact constructor is a good practice. This enforces business rules early and prevents invalid parameters from propagating further into the application logic, improving the robustness of the API.

        // Validate pageSize (1-100)
        if (pageSize != null && (pageSize < 1 || pageSize > 100)) {
            throw new InvalidParamsError(null,
                "pageSize must be between 1 and 100, got: " + pageSize, null);
        }

        // Validate historyLength (>= 0)
        if (historyLength != null && historyLength < 0) {
            throw new InvalidParamsError(null,
                "historyLength must be non-negative, got: " + historyLength, null);
        }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gemini-code-assist Isn't what you say here exactly the same as the code I have? I don't see the difference!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right, kabir! My apologies if my previous comment was unclear. I was highlighting that the code you've added for pageSize and historyLength validation is a great practice. The code block I included was meant to illustrate the good practice, and it perfectly matches what you've implemented. It's a solid addition to ensure robust parameter handling.

  - Add includingDefaultValueFields() to prevent missing fields in JSON responses
  - Fix parameter validation: enum UNRECOGNIZED, negative timestamps, zeroToNull
  - REST: accept multiple timestamp/status formats and add validation
  - JSON-RPC: add "Invalid enum value:" pattern for -32602 error code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants