{"record":{"id":"97a9af983f5f1614","repo":"mastra-ai/mastra","slug":"unknown-chunk-type-exhaustivecheck","errorCode":null,"errorMessage":"Unknown chunk type: ${exhaustiveCheck}","messagePattern":"Unknown chunk type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/stream/aisdk/v5/compat/ui-message.ts","lineNumber":247,"sourceCode":"    }\n\n    case 'abort': {\n      return part;\n    }\n\n    case 'tool-input-end': {\n      return;\n    }\n\n    case 'raw': {\n      // Raw chunks are not included in UI message streams\n      // as they contain provider-specific data for developer use\n      return;\n    }\n\n    default: {\n      const exhaustiveCheck: never = partType;\n      throw new Error(`Unknown chunk type: ${exhaustiveCheck}`);\n    }\n  }\n}\n","sourceCodeStart":229,"sourceCodeEnd":251,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/stream/aisdk/v5/compat/ui-message.ts#L229-L251","documentation":"convertFullStreamChunkToUIMessageStream translates internal stream chunks into AI SDK v5 UI message stream parts. The default branch is an exhaustiveness check; it throws when a chunk type arrives that has no mapping — usually a new/unknown Mastra chunk type or a mismatch between core and the v5 compat layer versions.","triggerScenarios":"Streaming with a model/provider emitting chunk types not yet handled (e.g. a new provider event), or a core chunk type added after this compat converter was written; custom middleware injecting unknown chunk types.","commonSituations":"Upgrading @mastra/core without upgrading stream/aisdk compat pieces (or vice versa); using a provider plugin that forwards proprietary chunks; manually pushing chunks into the stream pipeline.","solutions":["Align versions: upgrade @mastra/core (and related stream packages) together so all chunk types have mappings","Log partType from the error to identify the unhandled chunk and check whether a newer release handles it","Filter or transform unknown chunks in custom stream middleware before they reach the converter","Report the chunk type as an issue if it comes from an officially supported provider"],"exampleFix":"// before\npnpm add @mastra/core@0.10 @mastra/ai-sdk@0.9\n// after\npnpm add @mastra/core@latest @mastra/ai-sdk@latest  # matching versions","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"type KnownChunkType = 'text-delta' | 'reasoning-delta' | 'tool-call' | /* ... */;\nfunction isKnownChunkType(t: string): t is KnownChunkType {\n  // keep in sync with convertFullStreamChunkToUIMessageStream's switch\n  return KNOWN_CHUNK_TYPES.has(t as KnownChunkType);\n}","tryCatchPattern":"try {\n  for await (const part of uiMessageStream) { render(part); }\n} catch (e) {\n  if (String(e).startsWith('Unknown chunk type:')) {\n    logger.error('Unhandled stream chunk', { partType: String(e).split(': ')[1] });\n    // degrade gracefully: finish the message with what was rendered so far\n  } else throw e;\n}","preventionTips":["Keep @mastra/core and AI SDK compat packages on matching versions","Avoid injecting custom chunk types into the stream pipeline","When adding provider plugins, test streaming end-to-end with the v5 compat path","Pin versions in lockfile and upgrade core + compat packages together"],"tags":["streaming","aisdk","exhaustiveness","internals"],"backgroundTag":"unknown-chunk-type","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}