{"record":{"id":"2963f02063224ddc","repo":"mastra-ai/mastra","slug":"data-parts-are-not-supported-in-core-messages","errorCode":null,"errorMessage":"Data parts are not supported in core messages","messagePattern":"Data parts are not supported in core messages","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/server/src/server/a2a/protocol.ts","lineNumber":80,"sourceCode":"    content: message.parts.map(msg => convertToCoreMessagePart(msg)),\n  };\n}\n\nfunction convertToCoreMessagePart(part: Part) {\n  switch (part.kind) {\n    case 'text':\n      return {\n        type: 'text',\n        text: part.text,\n      } as const;\n    case 'file':\n      return {\n        type: 'file',\n        data: 'uri' in part.file ? new URL(part.file.uri) : part.file.bytes,\n        mimeType: part.file.mimeType!,\n      } as const;\n    case 'data':\n      throw new Error('Data parts are not supported in core messages');\n  }\n}\n","sourceCodeStart":62,"sourceCodeEnd":83,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/a2a/protocol.ts#L62-L83","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Have the remote agent return text or file parts instead of data parts.","Pre-process the A2A message and convert data parts to text (e.g. JSON.stringify the data) before convertToCoreMessage.","Filter out data parts from the message parts array before conversion.","Extend convertToCoreMessagePart to map data parts to a compatible core part type if your use case allows."],"exampleFix":"// before\nconst coreMsg = convertToCoreMessage(a2aMessage); // throws on data parts\n// after\nconst sanitized = { ...a2aMessage, parts: a2aMessage.parts.map(p =>\n  p.type === 'data' ? { type: 'text', text: JSON.stringify(p.data) } : p\n) };\nconst coreMsg = convertToCoreMessage(sanitized);","handlingStrategy":"validation","validationCode":"const hasDataParts = a2aMessage.parts.some(p => (p as { type?: string }).type === 'data');\nif (hasDataParts) {\n  throw new Error('Message contains data parts; convert or filter them before convertToCoreMessage');\n}","typeGuard":"const isConvertiblePart = (p: { type: string }): boolean => p.type === 'text' || p.type === 'file';","tryCatchPattern":"try {\n  coreMessage = convertToCoreMessage(a2aMessage);\n} catch (e) {\n  if (e.message === 'Data parts are not supported in core messages') {\n    coreMessage = convertToCoreMessage({\n      ...a2aMessage,\n      parts: a2aMessage.parts.map(p => p.type === 'data'\n        ? { type: 'text', text: JSON.stringify((p as any).data) }\n        : p),\n    });\n  } else throw e;\n}","preventionTips":["Sanitize A2A messages: convert data parts to text (JSON.stringify) or filter them before conversion.","When integrating external A2A agents, agree on text/file-only responses.","Add a unit test covering messages containing data parts."],"tags":["a2a","messages","unsupported-feature"],"backgroundTag":"unsupported-message-part","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}