{"record":{"id":"44db7ec419be2524","repo":"linshenkx/prompt-optimizer","slug":"empty-prompt-text","errorCode":null,"errorMessage":"Empty prompt.text","messagePattern":"Empty prompt\\.text","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/composables/app/useAppPromptGardenImport.ts","lineNumber":558,"sourceCode":"        : ''\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\n    if (!Array.isArray(data.variables)) {\n      throw new Error('Missing variables')\n    }\n    const variablesForImport = data.variables\n      .map((v): { name: string; defaultValue?: string } => {\n        if (!isPlainObject(v)) return { name: '' }\n        const name = typeof v.name === 'string' ? v.name.trim() : ''\n        const defaultValue = typeof v.defaultValue === 'string' ? v.defaultValue : undefined","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/composables/app/useAppPromptGardenImport.ts#L540-L576","documentation":"When format === 'text', the prompt body must include a `text` string with non-whitespace content. The importer rejects empty, all-whitespace, or non-string text because an imported prompt with no content is unusable.","triggerScenarios":"prompt.text is undefined, null, a non-string, an empty string '', or contains only spaces/newlines (fails t.trim()).","commonSituations":"Placeholder/draft prompts exported before content was written; whitespace-only templates; fields renamed upstream (e.g. 'content' instead of 'text').","solutions":["Ensure prompt.text is a non-empty string with at least one non-whitespace character","If the content lives under a different key upstream, fix the export or map the field before import","For intentionally blank prompts, block them at the Garden export side rather than importing"],"exampleFix":"// before\n{ \"prompt\": { \"format\": \"text\", \"text\": \"   \" } }\n\n// after\n{ \"prompt\": { \"format\": \"text\", \"text\": \"Summarize the following document.\" } }","handlingStrategy":"validation","validationCode":"if (fmt === 'text' && !(typeof raw.prompt.text === 'string' && raw.prompt.text.trim())) {\n  // block import: empty prompt body\n}","typeGuard":"const hasNonEmptyText = (p: unknown): boolean => isPlainObject(p) && typeof p.text === 'string' && p.text.trim().length > 0","tryCatchPattern":"catch (e) { if (e.message === 'Empty prompt.text') showImportError('Prompt has no content'); else throw e }","preventionTips":["Reject empty prompts at creation/export time","Trim-validate prompt bodies in the editor","Add fixture tests covering whitespace-only text"],"tags":["prompt-garden","empty-content","validation"],"backgroundTag":"empty-required-field","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}