fix!: Remove includingDefaultValueFields() from JsonFormat.printer() in JSONRPCUtils#692
fix!: Remove includingDefaultValueFields() from JsonFormat.printer() in JSONRPCUtils#692CokeLee777 wants to merge 1 commit intoa2aproject:mainfrom
Conversation
Summary of ChangesHello, 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 an issue where protobuf fields with default values were being unnecessarily included in the JSON output, leading to verbose and potentially misleading serialization. By adjusting the JSON formatting configuration, the change ensures that only explicitly set fields are present in the serialized JSON, improving data clarity and reducing payload size. The accompanying tests validate this corrected behavior, particularly for optional fields within message parts. Highlights
Changelog
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.
Code Review
This pull request correctly addresses the issue of default protobuf field values being serialized into JSON by removing the includingDefaultValueFields() call. The changes in JSONRPCUtils.java are correct, and the accompanying tests in JSONRPCUtilsTest.java effectively verify the fix. I have a suggestion to improve the test code's maintainability.
spec-grpc/src/test/java/io/a2a/grpc/utils/JSONRPCUtilsTest.java
Outdated
Show resolved
Hide resolved
…n JSONRPCUtils Remove the `includingDefaultValueFields()` call from `JsonFormat.printer()` in `toJsonRPCRequest` and `toJsonRPCResultResponse` methods to prevent unset protobuf fields (e.g. `filename`, `mediaType`, `metadata`) from being emitted as default values in the serialized JSON output. Add tests to verify that a `TextPart` with no metadata serializes with only the `text` field present, and that optional fields such as `filename`, `mediaType`, and `metadata` are excluded when not explicitly set. Fixes a2aproject#689
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request correctly addresses the issue of serializing default protobuf field values by removing includingDefaultValueFields() from the JsonFormat.printer(). The change is applied to both toJsonRPCRequest and toJsonRPCResultResponse methods, which is the correct approach. The new tests are well-structured and effectively verify that optional fields in TextPart (such as filename, mediaType, and metadata) are correctly omitted from the JSON output when they are not explicitly set, confirming the fix.
Description
Remove the
includingDefaultValueFields()call fromJsonFormat.printer()intoJsonRPCRequestandtoJsonRPCResultResponsemethods to prevent unset protobuf fields (e.g.filename,mediaType,metadata) from being emitted as default values in the serialized JSON output.Add tests to verify that a
TextPartwith no metadata serializes with only thetextfield present, and that optional fields such asfilename,mediaType, andmetadataare excluded when not explicitly set.Fixes #689