-
Notifications
You must be signed in to change notification settings - Fork 110
fix: Add Content-Type header to push notification requests #489
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
Summary of ChangesHello @jmesnil, 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 resolves a critical issue preventing successful push notifications by ensuring that all outgoing requests correctly specify their content type as 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 correctly adds the Content-Type header to push notification requests to fix the 415 Unsupported Media Type error. The changes are logical and the tests have been updated accordingly. I have a few suggestions to improve code maintainability and test robustness, mainly related to using constants for header strings and adding more specific assertions in tests. I've also pointed out an opportunity to reduce code duplication in one of the test files.
server-common/src/main/java/io/a2a/server/tasks/BasePushNotificationSender.java
Outdated
Show resolved
Hide resolved
server-common/src/test/java/io/a2a/server/tasks/InMemoryPushNotificationConfigStoreTest.java
Outdated
Show resolved
Hide resolved
server-common/src/test/java/io/a2a/server/tasks/InMemoryPushNotificationConfigStoreTest.java
Outdated
Show resolved
Hide resolved
server-common/src/test/java/io/a2a/server/tasks/PushNotificationSenderTest.java
Outdated
Show resolved
Hide resolved
server-common/src/test/java/io/a2a/server/tasks/PushNotificationSenderTest.java
Outdated
Show resolved
Hide resolved
server-common/src/test/java/io/a2a/server/tasks/PushNotificationSenderTest.java
Outdated
Show resolved
Hide resolved
server-common/src/test/java/io/a2a/server/tasks/PushNotificationSenderTest.java
Outdated
Show resolved
Hide resolved
Set `Content-Type: application/json` header when sending push notifications to prevent `415 Unsupported Media Type` errors. The request was previously defaulting to `application/octet-stream`. Add constants to A2AHttpClient to represent standard HTTP headers. Updates tests to verify that the `Content-Type` header is always present in push notification requests, regardless of whether authentication token is included. Fixes: a2aproject#486 Signed-off-by: Jeff Mesnil <jmesnil@ibm.com>
db5ae86 to
01f9653
Compare
|
/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 correctly addresses the issue of missing Content-Type headers in push notification requests by adding Content-Type: application/json. The implementation is straightforward and the associated tests have been updated comprehensively to verify the presence of this header in all relevant scenarios. The changes look good. I have one suggestion regarding the use of standard constants for HTTP headers to improve maintainability.
| String CONTENT_TYPE= "Content-Type"; | ||
| String APPLICATION_JSON= "application/json"; |
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.
To improve maintainability and adhere to standard practices, it's better to use predefined constants for common HTTP headers and media types instead of defining them manually. The Jakarta RESTful Web Services API (jakarta.ws.rs.core), which seems to be part of your project's dependencies, provides these.
I recommend removing these custom constants and using the standard ones throughout the codebase.
- Remove these lines.
- In files that use
CONTENT_TYPEandAPPLICATION_JSON, replace the static imports with:import static jakarta.ws.rs.core.HttpHeaders.CONTENT_TYPE; import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON;
This change would affect the following files in this PR:
extras/push-notification-config-store-database-jpa/src/test/java/io/a2a/extras/pushnotificationconfigstore/database/jpa/JpaPushNotificationConfigStoreTest.javaserver-common/src/main/java/io/a2a/server/tasks/BasePushNotificationSender.javaserver-common/src/test/java/io/a2a/server/tasks/InMemoryPushNotificationConfigStoreTest.javaserver-common/src/test/java/io/a2a/server/tasks/PushNotificationSenderTest.java
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 does not depend on jakarta.ws.rs.core and shouldn't be depending on it for the sake of a few common HTTP constants.
|
/gemini summary |
Summary of ChangesThis pull request addresses a critical bug where push notification requests were failing due to missing or incorrect "Content-Type" headers, leading to "415 Unsupported Media Type" errors. By explicitly setting "Content-Type: application/json" for these requests and introducing constants for HTTP header values, the change ensures reliable push notification delivery. The accompanying test updates provide robust verification of this fix, confirming the header's presence in various scenarios. Highlights
Changelog
Activity
|
…t#489) Set `Content-Type: application/json` header when sending push notifications to prevent `415 Unsupported Media Type` errors. The request was previously defaulting to `application/octet-stream`. Updates tests to verify that the `Content-Type` header is always present in push notification requests, regardless of whether authentication token is included. Fixes: a2aproject#486 Signed-off-by: Jeff Mesnil <jmesnil@ibm.com> - [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#486 🦕 Signed-off-by: Jeff Mesnil <jmesnil@ibm.com>
Set
Content-Type: application/jsonheader when sending push notificationsto prevent
415 Unsupported Media Typeerrors. The request was previouslydefaulting to
application/octet-stream.Updates tests to verify that the
Content-Typeheader is always presentin push notification requests, regardless of whether authentication
token is included.
Fixes: #486
Signed-off-by: Jeff Mesnil jmesnil@ibm.com
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 #486 🦕