{"record":{"id":"c3745cd151d52db6","repo":"danny-avila/LibreChat","slug":"missing-required-field-prompt","errorCode":null,"errorMessage":"Missing required field: prompt","messagePattern":"Missing required field: prompt","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"api/app/clients/tools/structured/DALLE3.js","lineNumber":155,"sourceCode":"\n  wrapInMarkdown(imageUrl) {\n    return `![generated image](${imageUrl})`;\n  }\n\n  returnValue(value) {\n    if (this.isAgent === true && typeof value === 'string') {\n      return [value, {}];\n    } else if (this.isAgent === true && typeof value === 'object') {\n      return [displayMessage, value];\n    }\n\n    return value;\n  }\n\n  async _call(data) {\n    const { prompt, quality = 'standard', size = '1024x1024', style = 'vivid' } = data;\n    if (!prompt) {\n      throw new Error('Missing required field: prompt');\n    }\n\n    let resp;\n    try {\n      resp = await this.openai.images.generate({\n        model: 'dall-e-3',\n        quality,\n        style,\n        size,\n        prompt: this.replaceUnwantedChars(prompt),\n        n: 1,\n      });\n    } catch (error) {\n      logger.error('[DALL-E-3] Problem generating the image:', error);\n      return this\n        .returnValue(`Something went wrong when trying to generate the image. The DALL-E API may be unavailable:\nError Message: ${error.message}`);\n    }","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/app/clients/tools/structured/DALLE3.js#L137-L173","documentation":"Runtime guard inside DALLE3._call(): the tool input must contain a `prompt` string before it will call OpenAI's images.generate. Thrown synchronously before any network request, so it is a caller/agent error, not an OpenAI-side failure.","triggerScenarios":"The agent/model invokes the DALLE3 tool with a JSON payload that omits `prompt`, passes prompt: null/undefined, or passes an object that destructures to a falsy prompt value.","commonSituations":"LLM tool-call emitted arguments in the wrong shape (e.g., {description: ...} instead of {prompt: ...}); a schema change to the tool that the model's cached instructions do not reflect; manual programmatic invocation that forgot the field; prompt coerced to empty string upstream by replaceUnwantedChars on whitespace-only input.","solutions":["Ensure the tool-call arguments include a non-empty `prompt` string before invocation.","Align the tool's JSON schema and the system prompt so the model emits `prompt` as the argument name.","If invoking programmatically, validate the payload shape before calling _call().","Sanitize the prompt upstream so whitespace-only strings are rejected before they reach the tool."],"exampleFix":"// before\nawait dalleTool.invoke({ description: 'a red fox' }); // wrong key\n\n// after\nawait dalleTool.invoke({ prompt: 'a red fox in snow, vivid' });","handlingStrategy":"validation","validationCode":"function buildDalleArgs(input) {\n  if (typeof input.prompt !== 'string' || input.prompt.trim() === '') {\n    throw new Error('DALLE3 requires a non-empty prompt string.');\n  }\n  return { prompt: input.prompt, quality: input.quality, size: input.size, style: input.style };\n}","typeGuard":"function hasPrompt(arg) {\n  return typeof arg?.prompt === 'string' && arg.prompt.trim().length > 0;\n}","tryCatchPattern":"try {\n  await dalleTool.invoke(args);\n} catch (e) {\n  if (/Missing required field: prompt/.test(e.message)) {\n    return 'Please provide a description for the image.';\n  }\n  throw e;\n}","preventionTips":["Make `prompt` required in the tool's JSON schema.","Strip/normalize whitespace upstream and reject empty prompts before they reach the tool.","When forwarding model tool-calls, validate the arg shape at the boundary."],"tags":["dalle3","input-validation","prompt","tool-args"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}