Skip to content

feat: Migrate Reactive Routes to Vert.X Web and add security tests#838

Open
kabir wants to merge 1 commit intoa2aproject:mainfrom
kabir:vertx-routes2
Open

feat: Migrate Reactive Routes to Vert.X Web and add security tests#838
kabir wants to merge 1 commit intoa2aproject:mainfrom
kabir:vertx-routes2

Conversation

@kabir
Copy link
Copy Markdown
Collaborator

@kabir kabir commented Apr 29, 2026

No description provided.

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 implements a significant architectural shift by migrating from Quarkus Reactive Routes to the programmatic Vert.x Web Router across several modules, including the JSON-RPC and REST reference servers. It introduces a VertxSecurityHelper to bridge Quarkus security with these raw Vert.x routes and adds comprehensive authentication tests for gRPC, JSON-RPC, and REST transports. Additionally, the AuthInterceptor now supports Basic authentication, and the JDK HTTP client includes explicit error handling for unauthorized and forbidden responses. Feedback suggests aligning error codes with the A2A specification for discovery endpoints and refactoring duplicated authentication error handling logic into a centralized handler.

Comment on lines +235 to +237
} catch (JsonProcessingException e) {
ctx.response().setStatusCode(500).end("Internal Server Error");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The error handling for JSON processing exceptions should be consistent with the A2A protocol specification, which typically maps such errors to a 400 Bad Request or a specific JSON-RPC error code rather than a 500 Internal Server Error.

References
  1. Adhere to the A2A protocol specification for error code mappings, even if other mappings seem more internally consistent.

Copy link
Copy Markdown
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 With @route, the method's return value (String) was automatically sent as the response body by the framework. If JsonProcessingException was
thrown, Quarkus Reactive Routes would have returned it as a 500 with the framework's default error handling — so the current 500 behavior is actually consistent with the old behavior.

The JsonProcessingException here can only happen when serializing the AgentCard to JSON (not parsing incoming data), so it's genuinely an
internal server error — the server failed to serialize its own data. A 400 would be wrong here since the client didn't send anything invalid.
Gemini's suggestion is incorrect in this context.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You are correct, kabir. In this specific context, where the JsonProcessingException occurs during the serialization of the AgentCard (an internal server operation) rather than during the parsing of client-provided input, a 500 Internal Server Error is the appropriate response. Thank you for clarifying the context of this exception.

Copy link
Copy Markdown
Collaborator

@ehsavoie ehsavoie left a comment

Choose a reason for hiding this comment

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

TestIdentityProvider is duplicated in reference/jsonrpc and reference/rest. It belongs in tests/server-common alongside AbstractA2AServerWithAuthTest.

AuthTestProfile is duplicated across all three modules with near-identical content. Shared config should move to tests/server-common.

* @throws RuntimeException if the task throws an exception
*/
public void runInRequestContext(RoutingContext ctx, Runnable task) {
ManagedContext requestContext = Arc.container().requestContext();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should protect the event loop thread:

if (Context.isOnEventLoopThread()) {
throw new IllegalStateException("Cannot perform blocking authentication on event loop thread. Use blockingHandler().");
}

} else {
ctx.response()
.setStatusCode(401)
.putHeader("WWW-Authenticate", "Basic realm=\"Quarkus\"")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't the authentication realm be configurable ??

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