Skip to content

fix: HTTP+JSON transport returns 501 instead of 400 for UnsupportedOperationError.#787

Merged
ehsavoie merged 2 commits intoa2aproject:mainfrom
ehsavoie:issue_765
Apr 10, 2026
Merged

fix: HTTP+JSON transport returns 501 instead of 400 for UnsupportedOperationError.#787
ehsavoie merged 2 commits intoa2aproject:mainfrom
ehsavoie:issue_765

Conversation

@ehsavoie
Copy link
Copy Markdown
Collaborator

@ehsavoie ehsavoie commented Apr 9, 2026

Returning the proper status code.

Fixes #765 🦕

@ehsavoie ehsavoie requested review from jmesnil and kabir and removed request for jmesnil April 9, 2026 15:13
Copy link
Copy Markdown
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 refactors the mapErrorToHttpStatus method in RestHandler.java to replace hardcoded HTTP status codes with values from the A2AErrorCodes enum. The review feedback suggests improving consistency by using the enum for InvalidAgentResponseError and removing a redundant check for InternalError that matches the default return value.

@ehsavoie
Copy link
Copy Markdown
Collaborator Author

ehsavoie commented Apr 9, 2026

/gemini review

Copy link
Copy Markdown
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 refactors the mapErrorToHttpStatus method in RestHandler.java to replace hardcoded HTTP status codes with calls to A2AErrorCodes.XXX.httpCode() for various error types, improving consistency. The review suggests a further simplification of this method by leveraging A2AErrorCodes.fromCode(error.getCode()) to derive the HTTP status, which would eliminate the need for multiple instanceof checks and align better with the A2A protocol specification for error code mappings.

…erationError.

Returning the proper status code.

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
@ehsavoie ehsavoie merged commit 6c76a93 into a2aproject:main Apr 10, 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]: HTTP+JSON transport returns 501 instead of 400 for UnsupportedOperationError

2 participants