Skip to content

A2A Message Connector fails with NullPointerException when history messages lack contextId #6537

@g3force

Description

@g3force

Describe the Bug

The A2A outbound connector throws a NullPointerException when the remote agent's Task response contains history messages without a contextId:

{"type":"java.lang.RuntimeException","message":"java.lang.NullPointerException: contextId is required"}

The A2aMessage record uses @AgenticAiRecord which applies defaultNotNull = true via RecordBuilder. This generates a builder that enforces Objects.requireNonNull(contextId, "contextId is required") on all fields not annotated with @Nullable.

When a Task response includes history messages (which don't carry a contextId), the conversion in A2aSdkObjectConverterImpl.java:54-58 calls convert(Message) for each entry. At line 34, message.getContextId() returns null, and the generated A2aMessageBuilder.build() throws the NPE.

Per the A2A Protocol specification, contextId on a Message is optional. The A2A Java SDK (io.a2a.spec.Message) also marks it as @Nullable.

Steps to Reproduce

  1. Configure an A2A outbound connector (Send Message operation)
  2. Send a message to a remote A2A agent that returns a Task response with history entries
  3. The history messages in the response do not include contextId (which is valid per the A2A spec)
  4. The connector fails with NullPointerException: contextId is required

Expected Behavior

The connector should handle Task responses with history messages that omit contextId, since the field is optional per the A2A specification.

Suggested fix: Add @Nullable to contextId in A2aMessage.java:25, consistent with how taskId is already annotated on line 26:

@Nullable String contextId,

Environment

  • OS: macOS
  • Library version: main branch (commit 8535117)
  • Camunda version: 8.9

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions