Skip to content

fix: Return UnsupportedOperationError when extendedAgentCard capabili…#736

Merged
kabir merged 1 commit intoa2aproject:mainfrom
kabir:issue-733
Mar 12, 2026
Merged

fix: Return UnsupportedOperationError when extendedAgentCard capabili…#736
kabir merged 1 commit intoa2aproject:mainfrom
kabir:issue-733

Conversation

@kabir
Copy link
Collaborator

@kabir kabir commented Mar 12, 2026

…ty is disabled

GetExtendedAgentCard now checks if the capability is enabled before checking if the card is configured. When capability is false, returns 501/UNIMPLEMENTED with UnsupportedOperationError instead of 400/FAILED_PRECONDITION.

Applied to all three transports: HTTP+JSON, JSON-RPC, and gRPC.

Fixes #733

…ty is disabled

GetExtendedAgentCard now checks if the capability is enabled before checking
if the card is configured. When capability is false, returns 501/UNIMPLEMENTED
with UnsupportedOperationError instead of 400/FAILED_PRECONDITION.

Applied to all three transports: HTTP+JSON, JSON-RPC, and gRPC.

Fixes a2aproject#733

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@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 refines the error handling for the GetExtendedAgentCard functionality by ensuring that if the extendedAgentCard capability is explicitly disabled, an UnsupportedOperationError is returned. This change standardizes the error response across gRPC, JSON-RPC, and HTTP+JSON transports, providing a clearer indication that the operation itself is not supported rather than merely misconfigured.

Highlights

  • Error Handling Logic: The GetExtendedAgentCard method across all transports (gRPC, JSON-RPC, HTTP+JSON) now first checks if the extendedAgentCard capability is enabled. If it is disabled, an UnsupportedOperationError is returned.
  • Standardized Error Response: Instead of returning a 400/FAILED_PRECONDITION (or ExtendedAgentCardNotConfiguredError) when the capability is disabled, the system now returns a 501/UNIMPLEMENTED status with an UnsupportedOperationError, providing a more accurate error type for disabled features.
  • Test Coverage: A test case in JSONRPCHandlerTest was updated to reflect the new error handling, ensuring that UnsupportedOperationError is correctly returned when the capability is not enabled.
Changelog
  • transport/grpc/src/main/java/io/a2a/transport/grpc/handler/GrpcHandler.java
    • Added a check for the extendedAgentCard capability at the beginning of the getExtendedAgentCard method.
    • Returned an UnsupportedOperationError via handleError if the capability is found to be disabled.
  • transport/jsonrpc/src/main/java/io/a2a/transport/jsonrpc/handler/JSONRPCHandler.java
    • Imported UnsupportedOperationError.
    • Modified the onGetExtendedCardRequest method to prioritize checking the extendedAgentCard capability.
    • Returned a GetExtendedAgentCardResponse with UnsupportedOperationError if the capability is disabled.
  • transport/jsonrpc/src/test/java/io/a2a/transport/jsonrpc/handler/JSONRPCHandlerTest.java
    • Updated the testOnGetExtendedAgentCard test to assert that an UnsupportedOperationError is returned when the extended agent card capability is not enabled.
  • transport/rest/src/main/java/io/a2a/transport/rest/handler/RestHandler.java
    • Modified the getExtendedAgentCard method to check for the extendedAgentCard capability first.
    • Threw an UnsupportedOperationError if the capability is disabled, before checking for card configuration.
Activity
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

The pull request refactors error handling for the getExtendedAgentCard operation across gRPC, JSON-RPC, and REST transports. It introduces an UnsupportedOperationError to specifically address cases where the extendedAgentCard capability is not enabled, differentiating this from scenarios where the card is simply not configured. This change involves adding a capability check before the configuration check in the respective handlers and updating a JSON-RPC test case to reflect the new error type.

Comment on lines +549 to +551
if (!getAgentCard().capabilities().extendedAgentCard()) {
handleError(responseObserver, new UnsupportedOperationError());
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This new check correctly identifies when the extendedAgentCard capability is not enabled and returns an UnsupportedOperationException. This is a more accurate exception than ExtendedAgentCardNotConfiguredError, as it indicates that the operation itself is not supported by the agent's capabilities, rather than just a configuration issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@gemini-code-assist This isn't an error right? It is the point of the PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Warning

Gemini is experiencing higher than usual traffic and was unable to create the review-comment-reply. Please try again in a few hours by commenting /gemini review-comment-reply.

Comment on lines +671 to +673
if (!agentCard.capabilities().extendedAgentCard()) {
return new GetExtendedAgentCardResponse(request.getId(), new UnsupportedOperationError());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Separating the capability check from the configuration check improves the clarity and precision of error reporting. Returning UnsupportedOperationException when the capability is disabled is more appropriate than ExtendedAgentCardNotConfiguredError, as it directly communicates that the operation is not supported by the agent's current capabilities.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@gemini-code-assist This isn't an error right? It is the point of the PR

Copy link
Contributor

Choose a reason for hiding this comment

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

You are absolutely correct, kabir. My apologies if my previous comment was unclear. I was indeed highlighting that the change to return UnsupportedOperationError when the capability is disabled is a significant improvement, as it accurately reflects the nature of the issue (lack of capability, not just misconfiguration). This change aligns perfectly with the objective of this pull request.

Comment on lines +792 to +794
if (!agentCard.capabilities().extendedAgentCard()) {
throw new UnsupportedOperationError();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the other transports, this change correctly prioritizes the capability check. Throwing UnsupportedOperationException when the extendedAgentCard capability is not enabled provides a more precise and actionable error message to the client.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@gemini-code-assist This isn't an error right? It is the point of the PR

Copy link
Contributor

Choose a reason for hiding this comment

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

You are absolutely right, kabir. My apologies for the potential confusion. When I referred to "error message," I was specifically referring to the UnsupportedOperationException itself as a type of error that is now being correctly thrown. This change is indeed the core point of the PR and a significant improvement, providing a more accurate and actionable response when the extendedAgentCard capability is not enabled. The change is correct and aligns perfectly with the PR's objective.

@kabir kabir merged commit 5f742ae into a2aproject:main Mar 12, 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.

[Bug]: GetExtendedAgentCard fails with the incorrect error when the capability is not available

2 participants