-
Notifications
You must be signed in to change notification settings - Fork 105
fix: ListTasks validation and serialization across all transports #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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.
server-common/src/main/java/io/a2a/server/tasks/InMemoryTaskStore.java
Outdated
Show resolved
Hide resolved
...re-database-jpa/src/main/java/io/a2a/extras/taskstore/database/jpa/JpaDatabaseTaskStore.java
Show resolved
Hide resolved
server-common/src/main/java/io/a2a/server/tasks/InMemoryTaskStore.java
Outdated
Show resolved
Hide resolved
server-common/src/main/java/io/a2a/server/tasks/InMemoryTaskStore.java
Outdated
Show resolved
Hide resolved
|
This one now has some conflicts. |
|
/gemini review |
There was a problem hiding this 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.
|
|
||
| // 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); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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);
}There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
These fixes are needed for the TCK tests in a2aproject/a2a-tck#93