-
Notifications
You must be signed in to change notification settings - Fork 104
feat!: 553:Adding pagination to JpaDatabasePushNotificationConfigStore #564
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 @Sathyvs, 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 enhances the push notification configuration storage and retrieval system by integrating robust pagination capabilities. The core change involves modifying 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
The pull request successfully introduces pagination support for JpaDatabasePushNotificationConfigStore and updates BasePushNotificationSender to correctly handle paginated results. The implementation utilizes keyset pagination based on createdAt and configId, which is a robust and efficient approach. The addition of the createdAt field to JpaPushNotificationConfig and its automatic population via @PrePersist is well-executed. Test cases have been appropriately updated to reflect the new ordering and ensure deterministic results for timestamp-based pagination, including the introduction of Thread.sleep to guarantee unique timestamps. Overall, the changes are well-structured and address the pagination requirement effectively.
| // This means the taskId and configId are same. This will not allow having multiple configs for a single Task. | ||
| // The configId is a required field in the spec and should not be empty |
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 comment on lines 42-43 states that configId is a required field in the spec and should not be empty. However, the code defaults notificationConfig.id() to taskId if it's null or empty. This implies that if a client doesn't provide a unique id for a PushNotificationConfig, it will be assigned the taskId as its configId. If the intention is to allow multiple push notification configurations for a single task, each requiring a unique configId, this defaulting behavior could prevent that by creating duplicate configIds (all equal to taskId). Please clarify if this behavior is intentional for a default configuration or if configId should always be explicitly provided and unique.
| // Based on the comments in the test case, if the pageToken is invalid start from the beginning. | ||
| } |
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 comment on line 92 suggests that if the pageToken is invalid, the system should "start from the beginning." However, the current implementation for tokenParts.length != 2 (i.e., the pageToken is not in the expected timestamp:id format) silently ignores the pageToken and proceeds to fetch the first page. For better clarity and consistency with the NumberFormatException handling (lines 112-116), it would be more robust to explicitly throw an InvalidParamsError when the pageToken is malformed or does not adhere to the expected structure. This provides clearer feedback to the client about incorrect usage.
// Keyset pagination: get tasks where timestamp < tokenTimestamp OR (timestamp = tokenTimestamp AND id > tokenId)
// All tasks have timestamps (TaskStatus canonical constructor ensures this)
queryBuilder.append(" AND (COALESCE(c.createdAt, :nullSentinel) < :tokenTimestamp OR (COALESCE(c.createdAt, :nullSentinel) = :tokenTimestamp AND c.id.configId > :tokenId))");
} else {
throw new io.a2a.spec.InvalidParamsError(null,
"Invalid pageToken format: pageToken must be in 'timestamp_millis:configId' format", 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.
@ehsavoie any suggestion on this about the default behavior ? I see many common public APIs ignore pagination token if they are invalid ?
|
@ehsavoie I have a few questions
|
I don't think so. I think it is implementation dependent. So as long as the active store understands it, you should be ok
Sorry not sure right now. Maybe Emmanuel will know on Monday, or I can look better then
Yes, that sounds reasonable. |
Description
Added Pagination support to getInfo method in JpaDatabasePushNotificationConfigStore
-- Follows the same pattern as that of JpaDatabaseTaskStore
Updated sendNotification(Task) in BasePushNotificationSender to paginate results if a nextToken is present
Fixes #553 🦕