-
Notifications
You must be signed in to change notification settings - Fork 131
fix!: Update the name of A2A headers #709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,13 +9,13 @@ public final class A2AHeaders { | |||||
| * HTTP header name for A2A protocol version. | ||||||
| * Used to communicate the protocol version that the client is using. | ||||||
| */ | ||||||
| public static final String X_A2A_VERSION = "X-A2A-Version"; | ||||||
| public static final String A2A_VERSION = "A2A-Version"; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This header name contains uppercase letters, which are not allowed in gRPC metadata keys. In gRPC Java, the
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://grpc.github.io/grpc-java/javadoc/io/grpc/Metadata.Key.html states something different |
||||||
|
|
||||||
| /** | ||||||
| * HTTP header name for A2A extensions. | ||||||
| * Used to communicate which extensions are requested by the client. | ||||||
| */ | ||||||
| public static final String X_A2A_EXTENSIONS = "X-A2A-Extensions"; | ||||||
| public static final String A2A_EXTENSIONS = "A2A-Extensions"; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This header name contains uppercase letters, which are not allowed in gRPC metadata keys. Using this constant in
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gemini, you are wrong considering the following documentation https://grpc.github.io/grpc-java/javadoc/io/grpc/Metadata.Key.html |
||||||
|
|
||||||
| /** | ||||||
| * HTTP header name for a push notification token. | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,8 +21,8 @@ | |
| * | ||
| * <h2>Captured Information</h2> | ||
| * <ul> | ||
| * <li><b>A2A Protocol Version</b>: {@code X-A2A-Version} header</li> | ||
| * <li><b>A2A Extensions</b>: {@code X-A2A-Extensions} header</li> | ||
| * <li><b>A2A Protocol Version</b>: {@code a2a-version} header</li> | ||
| * <li><b>A2A Extensions</b>: {@code a2a-extensions} header</li> | ||
| * <li><b>Complete Metadata</b>: All request headers via {@link io.grpc.Metadata}</li> | ||
| * <li><b>Method Name</b>: gRPC method being invoked</li> | ||
| * <li><b>Peer Information</b>: Client connection details</li> | ||
|
|
@@ -60,6 +60,13 @@ | |
| @ApplicationScoped | ||
| public class A2AExtensionsInterceptor implements ServerInterceptor { | ||
|
|
||
| private static final Metadata.Key<String> EXTENSIONS_KEY = Metadata.Key.of( | ||
| A2AHeaders.A2A_EXTENSIONS.toLowerCase(), | ||
| Metadata.ASCII_STRING_MARSHALLER); | ||
| private static final Metadata.Key<String> VERSION_KEY = Metadata.Key.of( | ||
| A2AHeaders.A2A_VERSION.toLowerCase(), | ||
| Metadata.ASCII_STRING_MARSHALLER); | ||
|
|
||
| /** | ||
| * Intercepts incoming gRPC calls to capture metadata and context information. | ||
| * | ||
|
|
@@ -68,8 +75,8 @@ public class A2AExtensionsInterceptor implements ServerInterceptor { | |
| * | ||
| * <p><b>Extraction Process:</b> | ||
| * <ol> | ||
| * <li>Extract {@code X-A2A-Version} header from metadata</li> | ||
| * <li>Extract {@code X-A2A-Extensions} header from metadata</li> | ||
| * <li>Extract {@code a2a-version} header from metadata</li> | ||
| * <li>Extract {@code a2a-extensions} header from metadata</li> | ||
| * <li>Capture complete {@link Metadata} object</li> | ||
| * <li>Capture gRPC method name from {@link ServerCall}</li> | ||
| * <li>Map gRPC method to A2A protocol method name</li> | ||
|
|
@@ -92,14 +99,9 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall( | |
| ServerCallHandler<ReqT, RespT> serverCallHandler) { | ||
|
|
||
| // Extract A2A protocol version header | ||
| Metadata.Key<String> versionKey = | ||
| Metadata.Key.of(A2AHeaders.X_A2A_VERSION, Metadata.ASCII_STRING_MARSHALLER); | ||
| String version = metadata.get(versionKey); | ||
|
|
||
| String version = metadata.get(VERSION_KEY); | ||
| // Extract A2A extensions header | ||
| Metadata.Key<String> extensionsKey = | ||
| Metadata.Key.of(A2AHeaders.X_A2A_EXTENSIONS, Metadata.ASCII_STRING_MARSHALLER); | ||
| String extensions = metadata.get(extensionsKey); | ||
| String extensions = metadata.get(EXTENSIONS_KEY); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The gRPC interceptor uses |
||
|
|
||
| // Create enhanced context with rich information (equivalent to Python's ServicerContext) | ||
| Context context = Context.current() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retrieving headers from the
ClientCallContextusing lowercase keys is fragile. HTTP header names are case-insensitive, and it's common for users to provide them with standard casing (e.g.,A2A-Version). The current implementation would fail to find such headers, leading to them being silently ignored.To make this more robust, it's better to iterate through the headers and perform a case-insensitive comparison.