{"record":{"id":"4d06bd331cc5016b","repo":"linshenkx/prompt-optimizer","slug":"missing-prompt-format","errorCode":null,"errorMessage":"Missing prompt.format","messagePattern":"Missing prompt\\.format","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/composables/app/useAppPromptGardenImport.ts","lineNumber":550,"sourceCode":"    if (data.schemaVersion !== 1) {\n      throw new Error('Unsupported Garden response schemaVersion')\n    }\n\n    const optimizerTarget = isPlainObject(data.optimizerTarget) ? data.optimizerTarget : null\n    const optimizerTargetKey =\n      optimizerTarget && typeof optimizerTarget.subModeKey === 'string'\n        ? optimizerTarget.subModeKey.trim()\n        : ''\n    if (!optimizerTargetKey) {\n      throw new Error('Missing optimizerTarget.subModeKey')\n    }\n\n    const prompt = isPlainObject(data.prompt) ? data.prompt : null\n    const format = prompt && (prompt.format === 'text' || prompt.format === 'messages')\n      ? (prompt.format as 'text' | 'messages')\n      : null\n    if (!format) {\n      throw new Error('Missing prompt.format')\n    }\n\n    let promptText: string | undefined\n    let promptMessages: ConversationMessage[] | undefined\n    if (format === 'text') {\n      const t = prompt && typeof prompt.text === 'string' ? prompt.text : ''\n      if (!t.trim()) {\n        throw new Error('Empty prompt.text')\n      }\n      promptText = t\n    } else {\n      const msgs = normalizeImportedConversationMessages(prompt?.messages)\n      if (!msgs.length) {\n        throw new Error('Empty prompt.messages')\n      }\n      promptMessages = msgs\n    }\n","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/composables/app/useAppPromptGardenImport.ts#L532-L568","documentation":"The prompt body object (data.prompt) must carry a `format` field that is exactly 'text' or 'messages'. Anything else — including a missing format, null, or a value like 'markdown' — throws this error before content parsing begins.","triggerScenarios":"data.prompt is null/not an object, prompt.format is undefined, or prompt.format is a string other than 'text'/'messages' (case-sensitive).","commonSituations":"New export format names upstream (e.g. 'chat', 'markdown'); truncated payloads; case mismatches like 'Text'; hand-edited JSON where format was deleted.","solutions":["Set prompt.format to exactly 'text' (plain string content) or 'messages' (conversation array)","Check for case sensitivity and trailing whitespace in the value","If upstream renamed formats, add a mapping in parseV1 or re-export"],"exampleFix":"// before\n{ \"prompt\": { \"format\": \"markdown\", \"text\": \"hi\" } }\n\n// after\n{ \"prompt\": { \"format\": \"text\", \"text\": \"hi\" } }","handlingStrategy":"type-guard","validationCode":"const fmt = raw?.prompt?.format\nif (fmt !== 'text' && fmt !== 'messages') { /* reject before import */ }","typeGuard":"const isPromptFormat = (v: unknown): v is 'text' | 'messages' => v === 'text' || v === 'messages'","tryCatchPattern":"catch (e) { if (e.message === 'Missing prompt.format') showImportError('Unsupported prompt format'); else throw e }","preventionTips":["Whitelist format values at export time","Use literal union types when building payloads","Watch for case-sensitive comparisons when hand-editing JSON"],"tags":["prompt-garden","validation","enum-value"],"backgroundTag":"schema-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}