{"record":{"id":"4c0f04ab761c1bbf","repo":"eyaltoledano/claude-task-master","slug":"prompt-must-be-a-non-empty-string","errorCode":null,"errorMessage":"Prompt must be a non-empty string","messagePattern":"Prompt must be a non-empty string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/ai/interfaces/ai-provider.interface.ts","lineNumber":416,"sourceCode":"\t\t\tstream: false,\n\t\t\ttopP: 1.0,\n\t\t\tfrequencyPenalty: 0.0,\n\t\t\tpresencePenalty: 0.0,\n\t\t\ttimeout: 30000,\n\t\t\tretries: 3,\n\t\t\t...this.config.defaultOptions,\n\t\t\t...userOptions\n\t\t};\n\t}\n\n\t/**\n\t * Validate prompt input\n\t * @param prompt - Prompt to validate\n\t * @throws Error if prompt is invalid\n\t */\n\tprotected validatePrompt(prompt: string): void {\n\t\tif (!prompt || typeof prompt !== 'string') {\n\t\t\tthrow new Error('Prompt must be a non-empty string');\n\t\t}\n\n\t\tif (prompt.trim().length === 0) {\n\t\t\tthrow new Error('Prompt cannot be empty or only whitespace');\n\t\t}\n\t}\n}\n","sourceCodeStart":398,"sourceCodeEnd":424,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/ai/interfaces/ai-provider.interface.ts#L398-L424","documentation":"validatePrompt() is the base provider's input guard for completion calls. It throws this error when the prompt is falsy or not a string — i.e. null, undefined, a number, or an empty string was passed where a prompt is required.","triggerScenarios":"generateCompletion(null as any); generateCompletion(undefined) when a variable failed to populate; passing an options object or message array instead of a string; calling with '' after a failed upstream string interpolation.","commonSituations":"Template variables left undefined in prompt-building code; API refactors that now pass message arrays to a method expecting a plain string; reading a prompt from config/DB that came back null.","solutions":["Ensure the prompt is a non-empty string before calling generateCompletion(prompt, options)","Stringify/serialize structured messages yourself before passing (e.g. messages.map(m => m.content).join('\\n'))","Coalesce defaults: const prompt = userPrompt ?? fallbackPrompt"],"exampleFix":"// before\nawait provider.generateCompletion(messages); // array, not string\n// after\nconst prompt = messages.map(m => m.content).join('\\n');\nawait provider.generateCompletion(prompt);","handlingStrategy":"validation","validationCode":"if (typeof prompt !== 'string' || prompt.length === 0) throw new Error('generateCompletion requires a non-empty string prompt');","typeGuard":"function isUsablePrompt(p: unknown): p is string {\n  return typeof p === 'string' && p.length > 0;\n}","tryCatchPattern":"try {\n  return await provider.generateCompletion(prompt, options);\n} catch (err) {\n  if (err.message === 'Prompt must be a non-empty string') {\n    throw new Error('Prompt building failed — check upstream variables');\n  }\n  throw err;\n}","preventionTips":["Type prompt parameters as string and avoid `as any` on message arrays","Build prompts in a single helper that asserts non-emptiness","Never pass structured message arrays directly to string-prompt APIs"],"tags":["ai-provider","input-validation","prompt"],"backgroundTag":"invalid-prompt-input","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}