Skip to content

[Bug]: Missing Content-Type: application/json request header for push notification request #486

@bianjp

Description

@bianjp

What happened?

The A2A server does not set the Content-Type: application/json header when sending push notifications, leading to a 415 Unsupported Media Type error. This occurs because the request defaults to application/octet-stream, which is not accepted by the client.

Relevant code: io.a2a.server.tasks.BasePushNotificationSender#dispatchNotification

private boolean dispatchNotification(Task task, PushNotificationConfig pushInfo) {
String url = pushInfo.url();
String token = pushInfo.token();
A2AHttpClient.PostBuilder postBuilder = httpClient.createPost();
if (token != null && !token.isBlank()) {
postBuilder.addHeader(X_A2A_NOTIFICATION_TOKEN, token);
}
String body;
try {
body = Utils.OBJECT_MAPPER.writeValueAsString(task);
} catch (JsonProcessingException e) {
LOGGER.debug("Error writing value as string: {}", e.getMessage(), e);
return false;
} catch (Throwable throwable) {
LOGGER.debug("Error writing value as string: {}", throwable.getMessage(), throwable);
return false;
}
try {
postBuilder
.url(url)
.body(body)
.post();
} catch (IOException | InterruptedException e) {
LOGGER.debug("Error pushing data to " + url + ": {}", e.getMessage(), e);
return false;
}
return true;

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions