fix: Return UnsupportedOperationError when extendedAgentCard capabili…#736
fix: Return UnsupportedOperationError when extendedAgentCard capabili…#736kabir merged 1 commit intoa2aproject:mainfrom
Conversation
…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>
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 refines the error handling for the Highlights
Changelog
Activity
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
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.
| if (!getAgentCard().capabilities().extendedAgentCard()) { | ||
| handleError(responseObserver, new UnsupportedOperationError()); | ||
| return; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@gemini-code-assist This isn't an error right? It is the point of the PR
There was a problem hiding this comment.
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.
| if (!agentCard.capabilities().extendedAgentCard()) { | ||
| return new GetExtendedAgentCardResponse(request.getId(), new UnsupportedOperationError()); | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@gemini-code-assist This isn't an error right? It is the point of the PR
There was a problem hiding this comment.
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.
| if (!agentCard.capabilities().extendedAgentCard()) { | ||
| throw new UnsupportedOperationError(); | ||
| } |
There was a problem hiding this comment.
@gemini-code-assist This isn't an error right? It is the point of the PR
There was a problem hiding this comment.
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.
…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