mastra-ai/mastra · error

Data parts are not supported in core messages

Error message

Data parts are not supported in core messages

What it means

convertToCoreMessagePart() maps A2A protocol message parts (text, file, data) into AI SDK core message parts. The 'data' part type (arbitrary structured JSON payloads from other A2A agents) has no equivalent core-message representation, so it is explicitly unsupported and throws this error rather than silently dropping data.

Source

Thrown at packages/server/src/server/a2a/protocol.ts:80

    content: message.parts.map(msg => convertToCoreMessagePart(msg)),
  };
}

function convertToCoreMessagePart(part: Part) {
  switch (part.kind) {
    case 'text':
      return {
        type: 'text',
        text: part.text,
      } as const;
    case 'file':
      return {
        type: 'file',
        data: 'uri' in part.file ? new URL(part.file.uri) : part.file.bytes,
        mimeType: part.file.mimeType!,
      } as const;
    case 'data':
      throw new Error('Data parts are not supported in core messages');
  }
}

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Have the remote agent return text or file parts instead of data parts.
  2. Pre-process the A2A message and convert data parts to text (e.g. JSON.stringify the data) before convertToCoreMessage.
  3. Filter out data parts from the message parts array before conversion.
  4. Extend convertToCoreMessagePart to map data parts to a compatible core part type if your use case allows.

Example fix

// before
const coreMsg = convertToCoreMessage(a2aMessage); // throws on data parts
// after
const sanitized = { ...a2aMessage, parts: a2aMessage.parts.map(p =>
  p.type === 'data' ? { type: 'text', text: JSON.stringify(p.data) } : p
) };
const coreMsg = convertToCoreMessage(sanitized);
Defensive patterns

Strategy: validation

Validate before calling

const hasDataParts = a2aMessage.parts.some(p => (p as { type?: string }).type === 'data');
if (hasDataParts) {
  throw new Error('Message contains data parts; convert or filter them before convertToCoreMessage');
}

Type guard

const isConvertiblePart = (p: { type: string }): boolean => p.type === 'text' || p.type === 'file';

Try / catch

try {
  coreMessage = convertToCoreMessage(a2aMessage);
} catch (e) {
  if (e.message === 'Data parts are not supported in core messages') {
    coreMessage = convertToCoreMessage({
      ...a2aMessage,
      parts: a2aMessage.parts.map(p => p.type === 'data'
        ? { type: 'text', text: JSON.stringify((p as any).data) }
        : p),
    });
  } else throw e;
}

Prevention

When it happens

Trigger: An incoming A2A message (via convertToCoreMessage) contains a part with kind/type 'data' — i.e. a remote agent responded with a DataPart instead of text or file parts.

Common situations: Interoperating with A2A agents that return structured JSON results as data parts; agent-to-agent workflows where a form/artifact payload is returned as a data part; specs/tests sending data parts.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/2963f02063224ddc. Report an issue: GitHub.