Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions a2a/src/main/java/com/google/adk/a2a/agent/RemoteA2AAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ private A2APartConverter partConverter(InvocationContext invocationContext) {
try {
return objectMapper.writeValueAsString(message);
} catch (JsonProcessingException e) {
logger.warn("Failed to serialize request", e);
// The exception can quote the request's content, so only its type is logged.
logger.warn("Failed to serialize request ({})", e.getClass().getSimpleName());
return null;
}
}
Expand Down Expand Up @@ -628,8 +629,9 @@ private void addMetadata(Event event, @Nullable ClientEvent clientEvent) {
.build());
}
} catch (JsonProcessingException e) {
// metadata serialization is not critical for agent execution, so we just log and continue.
logger.warn("Failed to serialize response metadata", e);
// Metadata serialization is not critical for agent execution, so we just log and continue.
// The exception can quote the peer's response, so only its type is logged.
logger.warn("Failed to serialize response metadata ({})", e.getClass().getSimpleName());
}
event.setCustomMetadata(eventMetadataBuilder.build());
}
Expand Down Expand Up @@ -775,7 +777,9 @@ private Event createAggregatedEvent(Content content, @Nullable ClientEvent trigg
.stringValue(objectMapper.writeValueAsString(triggerEvent))
.build());
} catch (JsonProcessingException e) {
logger.warn("Failed to serialize response metadata for aggregated event", e);
logger.warn(
"Failed to serialize response metadata for aggregated event ({})",
e.getClass().getSimpleName());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,8 @@ private static Map<String, Object> coerceToMap(Object value) {
try {
return objectMapper.readValue(str, Map.class);
} catch (JsonProcessingException e) {
logger.warn("Failed to parse map from string payload", e);
// The parser's message quotes the peer's text, so only the exception's type is logged.
logger.warn("Failed to parse map from string payload ({})", e.getClass().getSimpleName());
Map<String, Object> fallback = new HashMap<>();
fallback.put("value", str);
return fallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,17 +591,15 @@ private static Event updateEventMetadata(
/**
* Reports a dropped metadata value.
*
* <p>The parser's message quotes the peer's bytes, so the warning carries only the key and the
* exception type. A peer that streams malformed metadata would otherwise be able to write
* arbitrary content and a stack trace into the log on every event. The full exception is
* available at debug level.
* <p>The parser's message quotes the peer's bytes, so only the key and the exception type are
* logged, at any level. A peer that streams malformed metadata would otherwise be able to write
* arbitrary content and a stack trace into the log on every event.
*/
private static void logDroppedMetadata(A2AMetadataKey key, Exception e) {
logger.warn(
"Dropping unparseable A2A metadata for key {} ({})",
key.getType(),
e.getClass().getSimpleName());
logger.debug("Unparseable A2A metadata for key {}", key.getType(), e);
}

private static Event emptyEvent(InvocationContext invocationContext) {
Expand Down
Loading