-
Notifications
You must be signed in to change notification settings - Fork 120
feat!: Add pagination support to ListTaskPushNotificationConfig with Result wrapper #552
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
Conversation
…esult wrapper Implements pagination support for push notification config listing by introducing ListTaskPushNotificationConfigResult record, following the same pattern as ListTasksResult. This allows the API to return both the list of configs and a nextPageToken for pagination. Changes: - Created ListTaskPushNotificationConfigResult record with configs list and nextPageToken - Updated ListTaskPushNotificationConfigResponse to use Result type - Updated all server handlers to return Result wrapper - Updated ProtoUtils mappers for Result conversion - Updated all transport implementations (REST, gRPC, JSONRPC) on both client and server - Updated client interface and implementations - Fixed test to use Result type Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Summary of ChangesHello @ehsavoie, 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 significantly enhances the push notification configuration listing functionality by integrating pagination support. This change allows clients to retrieve push notification configurations in manageable chunks, improving performance and scalability for tasks with a large number of associated configurations. The update involved introducing a new result record, modifying API interfaces, updating all client and server-side transport layers, and implementing the pagination logic within the data storage components. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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 pagination support for listing task push notification configurations, which is a great enhancement for the API. The changes are comprehensive, touching all layers from the spec and client to the server handlers and storage implementations. The introduction of ListTaskPushNotificationConfigResult is a clean way to handle paginated results.
My main feedback is on the JpaDatabasePushNotificationConfigStore implementation, where the pagination is currently handled in-memory after fetching all records. This could lead to performance issues with large datasets. I've left a detailed comment with suggestions to move the pagination logic to the database query level for better scalability and to ensure deterministic ordering.
kabir
left a comment
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.
A few small issues, which would be good to look at :-)
...ificationconfigstore/database/jpa/JpaDatabasePushNotificationConfigStoreIntegrationTest.java
Outdated
Show resolved
Hide resolved
...ificationconfigstore/database/jpa/JpaDatabasePushNotificationConfigStoreIntegrationTest.java
Outdated
Show resolved
Hide resolved
.../a2a/extras/pushnotificationconfigstore/database/jpa/JpaPushNotificationConfigStoreTest.java
Outdated
Show resolved
Hide resolved
server-common/src/main/java/io/a2a/server/tasks/PushNotificationConfigStore.java
Outdated
Show resolved
Hide resolved
|
|
||
| List<PushNotificationConfig> pushNotificationConfigList = pushConfigStore.getInfo(params.id()); | ||
| if (pushNotificationConfigList == null || pushNotificationConfigList.isEmpty()) { | ||
| ListTaskPushNotificationConfigResult listTaskPushNotificationConfigResult = pushConfigStore.getInfo(new ListTaskPushNotificationConfigParams(params.id())); |
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.
Wrapping this in params here feels a bit odd. Maybe we could keep the original method and make that handle the wrapping if needed?
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.
the issue is i need to be able to return the new token too, so returning the list is no longer sufficient
server-common/src/test/java/io/a2a/server/tasks/InMemoryPushNotificationConfigStoreTest.java
Outdated
Show resolved
Hide resolved
spec/src/main/java/io/a2a/spec/ListTaskPushNotificationConfigResult.java
Outdated
Show resolved
Hide resolved
spec/src/main/java/io/a2a/spec/ListTaskPushNotificationConfigResult.java
Show resolved
Hide resolved
723027a to
b070cbf
Compare
…ginated API Updated all PushNotificationConfigStore implementations and tests to use the new ListTaskPushNotificationConfigParams/ListTaskPushNotificationConfigResult API instead of the old String-based getInfo method. Changes to implementations: - InMemoryPushNotificationConfigStore: Fixed bug where pageSize - 1 was used instead of pageSize, causing one less item to be returned than requested - JpaDatabasePushNotificationConfigStore: Implemented pagination logic matching the in-memory implementation - Added helper methods for pagination: findFirstIndex, convertPushNotificationConfig - Updated all test files with getInfoAsList helper method to maintain compatibility Comprehensive pagination tests added (20 new tests total): - InMemoryPushNotificationConfigStoreTest: 10 pagination tests - JpaDatabasePushNotificationConfigStoreIntegrationTest: 10 pagination tests Test coverage includes: - Basic pagination with pageSize - Multi-page navigation using pageToken - Last page handling (no nextPageToken) - Edge cases: zero/negative pageSize, pageSize larger than available items - Exact pageSize match - Invalid token handling - Empty task pagination - Full iteration across all pages - Explicit overlap detection (verifies no config appears in multiple pages) Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
- Fix @param error in PushNotificationConfigStore (blocking javadoc build) - Add complete javadoc to EventQueue and all public/protected members - Add javadoc to EventEnqueueHook, EventQueueClosedException - Add javadoc to TaskStore, JSONRPCException, NoTaskQueueException - Add javadoc to InMemoryTaskStore, Internal annotation - Fix typo in PushNotificationConfigStore ("emty" -> "empty") Reduces javadoc errors from 1 to 0 and warnings from 101 to 100. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
/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
This pull request introduces pagination support for listing task push notification configurations across the client, transport, and server components. The primary change involves updating the return type of listTaskPushNotificationConfigurations methods from List<TaskPushNotificationConfig> to a new ListTaskPushNotificationConfigResult record, which encapsulates both the list of configurations and a nextPageToken for pagination. The ListTaskPushNotificationConfigParams record was also updated to include pageSize and pageToken fields. Pagination logic was implemented in the JpaDatabasePushNotificationConfigStore and InMemoryPushNotificationConfigStore, using the PushNotificationConfig.token() field as the pagination cursor. Corresponding changes were made to client transports (gRPC, JSON-RPC, REST), request handlers, and numerous test cases to reflect the new return type and pagination parameters. A review comment highlighted a potential design flaw in using PushNotificationConfig.token() for pagination, suggesting that a config ID or index would be more appropriate, and also pointed out minor code style issues with extra spaces in a compact constructor declaration.
| public ListTaskPushNotificationConfigResult getInfo(ListTaskPushNotificationConfigParams params) { | ||
| List<PushNotificationConfig> configs = pushNotificationInfos.get(params.id()); | ||
| if (configs == null) { | ||
| return new ListTaskPushNotificationConfigResult(Collections.emptyList()); | ||
| } | ||
| if (params.pageSize() <= 0) { | ||
| return new ListTaskPushNotificationConfigResult(convertPushNotificationConfig(configs, params), null); | ||
| } | ||
| if (params.pageToken() != null && !params.pageToken().isBlank()) { | ||
| //find first index | ||
| int index = findFirstIndex(configs, params.pageToken()); | ||
| if (index < configs.size()) { | ||
| configs = configs.subList(index, configs.size()); | ||
| } | ||
| } | ||
| if (configs.size() <= params.pageSize()) { | ||
| return new ListTaskPushNotificationConfigResult(convertPushNotificationConfig(configs, params), null); | ||
| } | ||
| String newToken = configs.get(params.pageSize()).token(); | ||
| return new ListTaskPushNotificationConfigResult(convertPushNotificationConfig(configs.subList(0, params.pageSize()), params), newToken); | ||
| } |
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.
The pagination implementation uses PushNotificationConfig.token() to generate the nextPageToken. The token field is designed for webhook authentication, not for pagination. Using it as a pagination cursor is a design flaw and could be misleading.
For an in-memory store, a more appropriate pagination token would be based on the item's index or another unique, sortable attribute like the config ID. This would make the pagination logic clearer and avoid misusing the authentication token field.
For example, you could use the config ID as the token:
String newToken = configs.get(params.pageSize()).id();And then update findFirstIndex to search by ID.
spec/src/main/java/io/a2a/spec/ListTaskPushNotificationConfigParams.java
Outdated
Show resolved
Hide resolved
…arams.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…Result wrapper (a2aproject#552) # Description Implements pagination support for push notification config listing by introducing ListTaskPushNotificationConfigResult record, following the same pattern as ListTasksResult. This allows the API to return both the list of configs and a nextPageToken for pagination. Changes: - Created ListTaskPushNotificationConfigResult record with configs list and nextPageToken - Updated ListTaskPushNotificationConfigResponse to use Result type - Updated all server handlers to return Result wrapper - Updated ProtoUtils mappers for Result conversion - Updated all transport implementations (REST, gRPC, JSONRPC) on both client and server - Updated client interface and implementations - Fixed test to use Result type Updated all PushNotificationConfigStore implementations and tests to use the new ListTaskPushNotificationConfigParams/ListTaskPushNotificationConfigResult API instead of the old String-based getInfo method. Changes to implementations: - InMemoryPushNotificationConfigStore: Fixed bug where pageSize - 1 was used instead of pageSize, causing one less item to be returned than requested - JpaDatabasePushNotificationConfigStore: Implemented pagination logic matching the in-memory implementation - Added helper methods for pagination: findFirstIndex, convertPushNotificationConfig - Updated all test files with getInfoAsList helper method to maintain compatibility Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [X] Follow the [`CONTRIBUTING` Guide](../CONTRIBUTING.md). - [X] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [X] Ensure the tests pass - [X] Appropriate READMEs were updated (if necessary) Fixes a2aproject#535 🦕 --------- Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Kabir Khan <kkhan@redhat.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Description
Implements pagination support for push notification config listing by introducing
ListTaskPushNotificationConfigResult record, following the same pattern as
ListTasksResult. This allows the API to return both the list of configs and a
nextPageToken for pagination.
Changes:
- Created ListTaskPushNotificationConfigResult record with configs list and nextPageToken
- Updated ListTaskPushNotificationConfigResponse to use Result type
- Updated all server handlers to return Result wrapper
- Updated ProtoUtils mappers for Result conversion
- Updated all transport implementations (REST, gRPC, JSONRPC) on both client and server
- Updated client interface and implementations
- Fixed test to use Result type
Updated all PushNotificationConfigStore implementations and tests to use the new
ListTaskPushNotificationConfigParams/ListTaskPushNotificationConfigResult API
instead of the old String-based getInfo method.
Changes to implementations:
- InMemoryPushNotificationConfigStore: Fixed bug where pageSize - 1 was used
instead of pageSize, causing one less item to be returned than requested
- JpaDatabasePushNotificationConfigStore: Implemented pagination logic matching
the in-memory implementation
- Added helper methods for pagination: findFirstIndex, convertPushNotificationConfig
- Updated all test files with getInfoAsList helper method to maintain compatibility
Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTINGGuide.fix:which represents bug fixes, and correlates to a SemVer patch.feat:represents a new feature, and correlates to a SemVer minor.feat!:, orfix!:,refactor!:, etc., which represent a breaking change (indicated by the!) and will result in a SemVer major.Fixes #535 🦕