Skip to content

fix: Use case-insensitive matching for A2A headers in gRPC transport#721

Merged
kabir merged 1 commit intoa2aproject:mainfrom
jmesnil:A2A-Version
Mar 11, 2026
Merged

fix: Use case-insensitive matching for A2A headers in gRPC transport#721
kabir merged 1 commit intoa2aproject:mainfrom
jmesnil:A2A-Version

Conversation

@jmesnil
Copy link
Collaborator

@jmesnil jmesnil commented Mar 11, 2026

Follow-up to #709. Use equalsIgnoreCase when matching A2A headers instead of toLowerCase() key lookups.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 robustness of the gRPC transport layer by ensuring that A2A (Application-to-Application) headers, specifically a2a-version and a2a-extensions, are correctly recognized and processed regardless of their casing. This prevents potential issues where headers with non-standard casing might be overlooked, improving the reliability of communication.

Highlights

  • Case-Insensitive Header Matching: Implemented case-insensitive matching for a2a-version and a2a-extensions headers in gRPC transport by using equalsIgnoreCase instead of toLowerCase() for header key lookups.
  • Improved Header Parsing Logic: Refactored the header parsing logic to iterate through all context headers and apply equalsIgnoreCase for A2AHeaders.A2A_VERSION and A2AHeaders.A2A_EXTENSIONS.
Changelog
  • client/transport/grpc/src/main/java/io/a2a/client/transport/grpc/GrpcTransport.java
    • Changed header matching logic from toLowerCase() to equalsIgnoreCase() for A2A headers.
    • Updated header retrieval to iterate through all context headers for case-insensitive comparison.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 updates the gRPC transport to handle A2A headers in a case-insensitive manner, which is a robust approach to address the original issue. However, the implementation introduced a regression by removing null checks for header values, which can lead to unhandled NullPointerException and a potential Denial of Service (DoS) vulnerability. It is recommended to restore the null checks to ensure the robustness of the transport layer.

Follow-up to a2aproject#709. Use equalsIgnoreCase when matching A2A headers
instead of toLowerCase() key lookups.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jmesnil
Copy link
Collaborator Author

jmesnil commented Mar 11, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The GrpcTransport.java file was updated to handle a2a-version and a2a-extensions headers case-insensitively when creating gRPC metadata. The change involves iterating through all available headers and using equalsIgnoreCase for key comparison, rather than relying on specific lowercase header keys. The reviewer suggested an improvement to this new implementation, recommending the use of Java streams for enhanced readability and to leverage modern Java features when processing and filtering these headers.

Comment on lines +394 to 404
for (Map.Entry<String, String> header : context.getHeaders().entrySet()) {
if (A2AHeaders.A2A_VERSION.equalsIgnoreCase(header.getKey())) {
if (header.getValue() != null) {
metadata.put(VERSION_KEY, header.getValue());
}
} else if (A2AHeaders.A2A_EXTENSIONS.equalsIgnoreCase(header.getKey())) {
if (header.getValue() != null) {
metadata.put(EXTENSIONS_KEY, header.getValue());
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved readability and to leverage modern Java features, you could use a stream to process the headers. This separates the filtering of non-null values from the main logic of identifying and adding the relevant headers to the metadata.

            context.getHeaders().entrySet().stream()
                    .filter(header -> header.getValue() != null)
                    .forEach(header -> {
                        if (A2AHeaders.A2A_VERSION.equalsIgnoreCase(header.getKey())) {
                            metadata.put(VERSION_KEY, header.getValue());
                        } else if (A2AHeaders.A2A_EXTENSIONS.equalsIgnoreCase(header.getKey())) {
                            metadata.put(EXTENSIONS_KEY, header.getValue());
                        }
                    });

@kabir kabir merged commit e252a0f into a2aproject:main Mar 11, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants