Skip to content

feat: Add ability to skip transport validation#266

Merged
kabir merged 2 commits intoa2aproject:mainfrom
kabir:grpc-tm
Sep 11, 2025
Merged

feat: Add ability to skip transport validation#266
kabir merged 2 commits intoa2aproject:mainfrom
kabir:grpc-tm

Conversation

@kabir
Copy link
Collaborator

@kabir kabir commented Sep 11, 2025

Also add missing validation to the RestHandler.

Fixes #264 🦕

Also add missing validation to the RestHandler.
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.

Summary of Changes

Hello @kabir, 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 flexibility of AgentCard transport validation by allowing developers to selectively skip validation checks using system properties. It also addresses a missing validation call in the RestHandler to ensure consistent application of transport configuration rules. These changes improve the robustness and configurability of the system's transport layer.

Highlights

  • Transport Validation Skipping: Introduced system properties to allow skipping of AgentCard transport validation, either globally or for specific transport protocols (JSONRPC, gRPC, REST).
  • RestHandler Validation Enforcement: Ensured the RestHandler explicitly performs AgentCard transport validation upon initialization, addressing a previously missing validation call.
  • Comprehensive Testing: Added comprehensive unit tests to verify the correct behavior of the new transport validation skip functionality.
  • Configuration Correction: Corrected a transport protocol string in a test properties file from "HTTP_JSON" to "HTTP+JSON" for consistency.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 introduces a valuable feature to skip transport validation via system properties, enhancing flexibility. The implementation is solid, with thorough test coverage for the new functionality. Additionally, it correctly adds a missing validation step to the RestHandler. My feedback includes a couple of suggestions aimed at improving code maintainability and reducing duplication.

Comment on lines +145 to +154
private static boolean isTransportSkipped(String transport) {
if (transport.equals(TransportProtocol.JSONRPC.asString())) {
return Boolean.getBoolean(SKIP_JSONRPC_PROPERTY);
} else if (transport.equals(TransportProtocol.GRPC.asString())){
return Boolean.getBoolean(SKIP_GRPC_PROPERTY);
} else if (transport.equals(TransportProtocol.HTTP_JSON.asString())) {
return Boolean.getBoolean(SKIP_REST_PROPERTY);
}
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The if-else if chain can be simplified by using a switch statement. This improves readability and is slightly more efficient, making the code easier to maintain.

    private static boolean isTransportSkipped(String transport) {
        switch (transport) {
            case "JSONRPC":
                return Boolean.getBoolean(SKIP_JSONRPC_PROPERTY);
            case "GRPC":
                return Boolean.getBoolean(SKIP_GRPC_PROPERTY);
            case "HTTP+JSON":
                return Boolean.getBoolean(SKIP_REST_PROPERTY);
            default:
                return false;
        }
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I want to use constants

Comment on lines 133 to 142
AgentCard agentCard = new AgentCard.Builder()
.name("Test Agent")
.description("Test Description")
.url("http://localhost:9999")
.version("1.0.0")
.capabilities(new AgentCapabilities.Builder().build())
.defaultInputModes(Collections.singletonList("text"))
.defaultOutputModes(Collections.singletonList("text"))
.skills(Collections.emptyList())
.build();
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There is significant code duplication across the new test methods for building AgentCard instances. To improve maintainability and reduce this duplication, consider extracting the common AgentCard.Builder setup into a private helper method.

For example, you could create a method like this:

private AgentCard.Builder createTestAgentCardBuilder() {
    return new AgentCard.Builder()
            .name("Test Agent")
            .description("Test Description")
            .url("http://localhost:9999")
            .version("1.0.0")
            .capabilities(new AgentCapabilities.Builder().build())
            .defaultInputModes(Collections.singletonList("text"))
            .defaultOutputModes(Collections.singletonList("text"))
            .skills(Collections.emptyList());
}

Then, each test can call this helper and customize the agent card as needed, for instance: createTestAgentCardBuilder().preferredTransport(...).build().

@kabir kabir merged commit e5dcb4d into a2aproject:main Sep 11, 2025
3 checks passed
kabir added a commit to kabir/a2a-java that referenced this pull request Dec 23, 2025
Also add missing validation to the RestHandler.

Fixes a2aproject#264 🦕
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.

[Feat]: Add ability to skip transport validation

2 participants