{"record":{"id":"ba3b76712bc7c9df","repo":"mastra-ai/mastra","slug":"unsupported-output-format-format","errorCode":null,"errorMessage":"Unsupported output format: ${format}","messagePattern":"Unsupported output format: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/message-list/utils/convert-messages.ts","lineNumber":84,"sourceCode":"   */\n  to(format: 'AIV6.UI'): AIV6.UIMessage[];\n  to(format: OutputFormat): unknown[] {\n    switch (format) {\n      // Old format keys (backward compatibility)\n      case 'Mastra.V2':\n        return this.messageList.get.all.db();\n      case 'AIV4.UI':\n        return this.messageList.get.all.aiV4.ui();\n      case 'AIV4.Core':\n        return this.messageList.get.all.aiV4.core();\n      case 'AIV5.UI':\n        return this.messageList.get.all.aiV5.ui();\n      case 'AIV5.Model':\n        return this.messageList.get.all.aiV5.model();\n      case 'AIV6.UI':\n        return this.messageList.get.all.aiV6.ui();\n      default:\n        throw new Error(`Unsupported output format: ${format}`);\n    }\n  }\n}\n\n/**\n * Convert messages from any supported format to another format.\n *\n * @param messages - Input messages in any supported format. Accepts:\n *   - AI SDK v4 formats: UIMessage, CoreMessage, Message\n *   - AI SDK v5 formats: UIMessage, ModelMessage\n *   - Mastra formats: MastraMessageV1 (input only), MastraDBMessage\n *   - Simple strings (will be converted to user messages)\n *   - Arrays of any of the above\n *\n * @returns A converter object with a `.to()` method to specify the output format\n *\n * @example\n * ```typescript","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/message-list/utils/convert-messages.ts#L66-L102","documentation":"AgentMemory or message conversion code only supports a fixed set of output format strings ('AIV5.UI', 'AIV5.Model', 'AIV6.UI', etc.). This error means the `format` passed to the message-dump/convert API did not match any case in the switch. It is a strict enum-guard, so any typo or unsupported format string fails fast instead of silently returning undefined.","triggerScenarios":"Calling a method that converts MessageList contents (e.g. agent memory dump / message serialization) with a `format` string that is not one of the supported keys handled in convert-messages.ts, such as 'AIV4.UI', 'v5-ui', or a lowercased 'aiv5.ui'.","commonSituations":"Typos in format constants; copying code from an older version of Mastra that used different format names; dynamically building the format string from config; passing a format supported in a different package/version that core doesn't handle yet.","solutions":["Use one of the exact supported format literals shown in the switch: 'AIV5.UI', 'AIV5.Model', 'AIV6.UI' (check convert-messages.ts for the full list).","Import a format constant/type from the library instead of typing the string by hand, so TypeScript catches invalid values at compile time.","If you need a format not in the list, convert the output yourself (e.g. take 'AIV5.UI' and transform to your target shape) rather than passing a custom format string.","If on an older Mastra version, upgrade — new format keys may have been added."],"exampleFix":"// before\nconst messages = memory.dump('v5-ui');\n// after\nconst messages = memory.dump('AIV5.UI');","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = ['AIV5.UI', 'AIV5.Model', 'AIV6.UI'] as const;\ntype Format = typeof SUPPORTED[number];\nconst isFormat = (f: string): f is Format => (SUPPORTED as readonly string[]).includes(f);\nif (!isFormat(format)) throw new TypeError(`format must be one of ${SUPPORTED.join(', ')}`);","typeGuard":"function isOutputFormat(f: unknown): f is 'AIV5.UI' | 'AIV5.Model' | 'AIV6.UI' {\n  return f === 'AIV5.UI' || f === 'AIV5.Model' || f === 'AIV6.UI';\n}","tryCatchPattern":"try {\n  messages = dump(format);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unsupported output format')) {\n    messages = dump('AIV5.UI'); // fallback to default format\n  } else throw e;\n}","preventionTips":["Always use the exported format constants/types instead of raw strings","Let TypeScript's literal union types catch invalid formats at compile time","Centralize format selection in one config module"],"tags":["configuration","invalid-argument","message-conversion"],"backgroundTag":"invalid-enum-value","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}