{"record":{"id":"1578711e0aca2edc","repo":"danny-avila/LibreChat","slug":"missing-required-field-prompt-157871","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/OpenAIImageTools.js","lineNumber":127,"sourceCode":"  const imageFiles = fields.imageFiles ?? [];\n\n  /**\n   * Image Generation Tool\n   */\n  const imageGenTool = tool(\n    async (\n      {\n        prompt,\n        background = 'auto',\n        n = 1,\n        output_compression = 100,\n        quality = 'auto',\n        size = 'auto',\n      },\n      runnableConfig,\n    ) => {\n      if (!prompt) {\n        throw new Error('Missing required field: prompt');\n      }\n      const clientConfig = { ...closureConfig };\n      const proxyDispatcher = getProxyDispatcher();\n      if (proxyDispatcher) {\n        clientConfig.fetchOptions = {\n          dispatcher: proxyDispatcher,\n        };\n      }\n\n      /** @type {OpenAI} */\n      const openai = new OpenAI(clientConfig);\n      let output_format = imageOutputType;\n      if (\n        background === 'transparent' &&\n        output_format !== EImageOutputType.PNG &&\n        output_format !== EImageOutputType.WEBP\n      ) {\n        logger.warn(","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/app/clients/tools/structured/OpenAIImageTools.js#L109-L145","documentation":"Runtime guard at the top of the image_gen_oai tool callback: the destructured `prompt` must be present before it constructs the OpenAI client and calls images.generate. Thrown before any network I/O.","triggerScenarios":"The OpenAI image-generation tool is invoked with a payload where `prompt` is missing/null/empty — e.g., only quality/size/background were supplied.","commonSituations":"The model emitted tool args without prompt; the JSON schema does not mark prompt required so the model omitted it; programmatic caller built args from optional input; refactoring renamed the field.","solutions":["Always include a non-empty `prompt` string in the tool-call arguments.","Mark `prompt` as required in the tool schema.","Validate args at the boundary before invoking the tool.","Inspect the raw tool-call JSON to confirm the model is emitting `prompt` and not a synonym."],"exampleFix":"// before\nawait imageGenTool.invoke({ size: '1024x1024' }); // throws\n\n// after\nawait imageGenTool.invoke({ prompt: 'a fox in snow', size: '1024x1024' });","handlingStrategy":"validation","validationCode":"function buildImageGenArgs(input) {\n  if (typeof input.prompt !== 'string' || !input.prompt.trim()) {\n    throw new Error('image_gen_oai requires a non-empty prompt.');\n  }\n  return input;\n}","typeGuard":"function hasPrompt(arg) {\n  return typeof arg?.prompt === 'string' && arg.prompt.trim().length > 0;\n}","tryCatchPattern":"try {\n  await imageGenTool.invoke(args);\n} catch (e) {\n  if (/Missing required field: prompt/.test(e.message)) return 'A prompt is required to generate an image.';\n  throw e;\n}","preventionTips":["Require `prompt` in the image_gen_oai schema.","Validate tool-call args before invoking.","Log raw model tool-call JSON to catch missing prompts."],"tags":["openai-image","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"}