Skip to content

Commit 6dc6ee1

Browse files
authored
Merge branch 'main' into dependabot/maven/quarkus-0c0756794a
2 parents 771ffc8 + 4d746aa commit 6dc6ee1

29 files changed

Lines changed: 972 additions & 58 deletions

File tree

.github/workflows/create-github-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
id: release_notes
3232
uses: actions/github-script@v9
3333
with:
34+
github-token: ${{ secrets.GITHUB_TOKEN }}
3435
script: |
3536
const version = '${{ steps.version.outputs.version }}';
3637
@@ -88,6 +89,7 @@ jobs:
8889
- name: Create GitHub Release
8990
uses: actions/github-script@v9
9091
with:
92+
github-token: ${{ secrets.GITHUB_TOKEN }}
9193
script: |
9294
const version = '${{ steps.version.outputs.version }}';
9395
const tag = context.ref.replace('refs/tags/', '');

client/transport/rest/src/main/java/org/a2aproject/sdk/client/transport/rest/RestTransport.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.concurrent.CompletableFuture;
2323
import java.util.concurrent.atomic.AtomicReference;
2424
import java.util.function.Consumer;
25+
import java.util.logging.Level;
2526
import java.util.logging.Logger;
2627

2728
import com.google.protobuf.InvalidProtocolBufferException;
@@ -36,6 +37,7 @@
3637
import org.a2aproject.sdk.client.transport.spi.interceptors.ClientCallContext;
3738
import org.a2aproject.sdk.client.transport.spi.interceptors.ClientCallInterceptor;
3839
import org.a2aproject.sdk.client.transport.spi.interceptors.PayloadAndHeaders;
40+
import org.a2aproject.sdk.grpc.utils.ProtoJsonUtils;
3941
import org.a2aproject.sdk.grpc.utils.ProtoUtils;
4042
import org.a2aproject.sdk.jsonrpc.common.json.JsonProcessingException;
4143
import org.a2aproject.sdk.jsonrpc.common.json.JsonUtil;
@@ -431,19 +433,24 @@ private String sendPostRequest(String url, PayloadAndHeaders payloadAndHeaders)
431433
A2AHttpClient.PostBuilder builder = createPostBuilder(url, payloadAndHeaders);
432434
A2AHttpResponse response = builder.post();
433435
if (!response.success()) {
434-
log.fine("Error on POST processing " + JsonFormat.printer().print((MessageOrBuilder) payloadAndHeaders.getPayload()));
436+
if (log.isLoggable(Level.FINE)) {
437+
log.fine("Error on POST processing " + ProtoJsonUtils.toJson(JsonFormat.printer(), (MessageOrBuilder) payloadAndHeaders.getPayload()));
438+
}
435439
throw RestErrorMapper.mapRestError(response);
436440
}
437441
return response.body();
438442
}
439443

440444
private A2AHttpClient.PostBuilder createPostBuilder(String url, PayloadAndHeaders payloadAndHeaders) throws JsonProcessingException, InvalidProtocolBufferException {
441-
log.fine(JsonFormat.printer().print((MessageOrBuilder) payloadAndHeaders.getPayload()));
445+
String body = ProtoJsonUtils.toJson(JsonFormat.printer(), (MessageOrBuilder) payloadAndHeaders.getPayload());
446+
if (log.isLoggable(Level.FINE)) {
447+
log.fine(body);
448+
}
442449
A2AHttpClient.PostBuilder postBuilder = httpClient.createPost()
443450
.url(url)
444451
.addHeader("Content-Type", "application/json")
445452
.addHeader(A2AHeaders.A2A_VERSION, AgentInterface.CURRENT_PROTOCOL_VERSION)
446-
.body(JsonFormat.printer().print((MessageOrBuilder) payloadAndHeaders.getPayload()));
453+
.body(body);
447454

448455
if (payloadAndHeaders.getHeaders() != null) {
449456
for (Map.Entry<String, String> entry : payloadAndHeaders.getHeaders().entrySet()) {

common/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
<groupId>org.slf4j</groupId>
2222
<artifactId>slf4j-api</artifactId>
2323
</dependency>
24+
<dependency>
25+
<groupId>org.junit.jupiter</groupId>
26+
<artifactId>junit-jupiter-api</artifactId>
27+
<scope>test</scope>
28+
</dependency>
2429
</dependencies>
2530

2631
</project>
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package org.a2aproject.sdk.common;
22

3+
/** Standard error message constants for A2A authentication and authorization failures. */
34
public final class A2AErrorMessages {
45

56
private A2AErrorMessages() {
6-
// Prevent instantiation
77
}
88

9+
/** Error message returned when client credentials are missing or invalid. */
910
public static final String AUTHENTICATION_FAILED = "Authentication failed: Client credentials are missing or invalid";
11+
/** Error message returned when the client lacks permission for the requested operation. */
1012
public static final String AUTHORIZATION_FAILED = "Authorization failed: Client does not have permission for the operation";
1113
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.a2aproject.sdk.common;
22

3+
/** Common MIME type constants. */
34
public interface MediaType {
45

6+
/** MIME type for JSON content: {@code application/json}. */
57
String APPLICATION_JSON = "application/json";
68
}

common/src/main/java/org/a2aproject/sdk/common/package-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** Common shared types and constants for the A2A SDK. */
12
@NullMarked
23
package org.a2aproject.sdk.common;
34

common/src/main/java/org/a2aproject/sdk/util/Assert.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
import org.jspecify.annotations.Nullable;
44

5+
/** Parameter validation utilities. */
56
public final class Assert {
67

8+
private Assert() {
9+
}
10+
711
/**
812
* Check that the named parameter is not {@code null}. Use a standard exception message if it is.
913
*
@@ -27,6 +31,12 @@ private static <T> void checkNotNullParamChecked(final String name, final @Nulla
2731
}
2832
}
2933

34+
/**
35+
* Validates that the given value is a legal JSON-RPC id ({@code null}, {@code String}, or {@code Number}).
36+
*
37+
* @param value the id value to validate
38+
* @throws IllegalArgumentException if the value is not a valid JSON-RPC id type
39+
*/
3040
public static void isValidJsonRpcId(@Nullable Object value) {
3141
if (! (value == null || value instanceof String || value instanceof Number)) {
3242
throw new IllegalArgumentException("JSON-RPC id must be null, a String, or a Number");
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.a2aproject.sdk.util;
2+
3+
/**
4+
* Utilities for removing HTML escaping applied by Gson's {@code JsonWriter}
5+
* when {@code htmlSafe} is enabled (the default).
6+
*/
7+
public final class HtmlEscapeUtils {
8+
9+
private HtmlEscapeUtils() {
10+
}
11+
12+
/**
13+
* Removes HTML escaping applied by Gson's {@code JsonWriter} when
14+
* {@code htmlSafe} is enabled (the default). Restores literal
15+
* {@code <}, {@code >}, {@code &}, {@code =}, and {@code '}.
16+
* <p>
17+
* Gson also escapes U+2028 (line separator) and U+2029 (paragraph separator) in HTML-safe
18+
* mode, but those are left as-is because they are valid JSON encodings that preserve the
19+
* original characters without data corruption.
20+
*
21+
* @param json the JSON string potentially containing HTML-escaped sequences
22+
* @return the JSON string with literal characters restored
23+
*/
24+
public static String removeHtmlEscaping(String json) {
25+
return json.replace("\\u003c", "<")
26+
.replace("\\u003e", ">")
27+
.replace("\\u0026", "&")
28+
.replace("\\u003d", "=")
29+
.replace("\\u0027", "'");
30+
}
31+
}

common/src/main/java/org/a2aproject/sdk/util/NotNull.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
@Retention(RetentionPolicy.CLASS)
1010
@Target({ ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PARAMETER })
1111
@Documented
12+
/** Marks an element as non-null for static analysis. */
1213
public @interface NotNull {
1314
}

common/src/main/java/org/a2aproject/sdk/util/package-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** General-purpose utilities for the A2A SDK. */
12
@NullMarked
23
package org.a2aproject.sdk.util;
34

0 commit comments

Comments
 (0)