{"record":{"id":"81d7a8c71f0c4299","repo":"danny-avila/LibreChat","slug":"missing-required-field-prompt-81d7a8","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/FluxAPI.js","lineNumber":210,"sourceCode":"  async _call(data) {\n    const { action = 'generate', ...imageData } = data;\n\n    // Use provided API key for this request if available, otherwise use default\n    const requestApiKey = this.apiKey || this.getApiKey();\n\n    // Handle list_finetunes action\n    if (action === 'list_finetunes') {\n      return this.getMyFinetunes(requestApiKey);\n    }\n\n    // Handle finetuned generation\n    if (action === 'generate_finetuned') {\n      return this.generateFinetunedImage(imageData, requestApiKey);\n    }\n\n    // For generate action, ensure prompt is provided\n    if (!imageData.prompt) {\n      throw new Error('Missing required field: prompt');\n    }\n\n    let payload = {\n      prompt: imageData.prompt,\n      prompt_upsampling: imageData.prompt_upsampling || false,\n      safety_tolerance: imageData.safety_tolerance || 6,\n      output_format: imageData.output_format || 'png',\n    };\n\n    // Add optional parameters if provided\n    if (imageData.width) {\n      payload.width = imageData.width;\n    }\n    if (imageData.height) {\n      payload.height = imageData.height;\n    }\n    if (imageData.steps) {\n      payload.steps = imageData.steps;","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/app/clients/tools/structured/FluxAPI.js#L192-L228","documentation":"Guard in FluxAPI._call() for the default `generate` action: after the list_finetunes and generate_finetuned branches are skipped, the remaining code path requires `imageData.prompt`. Distinct from the finetuned path which has its own prompt check (error 5).","triggerScenarios":"Calling the Flux tool with `action: 'generate'` (the default when action is omitted) and a payload whose `prompt` field is missing, null, undefined, or empty string.","commonSituations":"The model emitted tool args without a prompt (e.g., only width/height); a programmatic caller built the payload from optional user input that was empty; action defaulted to 'generate' when the caller intended a different action; schema mismatch between the tool description and what the model produced.","solutions":["Supply a non-empty `prompt` string in the tool arguments for the generate action.","Validate the payload before invoking the tool when prompt comes from user input.","Re-check the tool's JSON schema so `prompt` is required and the model is steered to emit it.","If the caller intended a finetuned run, set `action: 'generate_finetuned'` explicitly."],"exampleFix":"// before\nawait fluxTool.invoke({ action: 'generate', width: 1024 });\n\n// after\nawait fluxTool.invoke({ action: 'generate', prompt: 'a neon koi, cinematic', width: 1024 });","handlingStrategy":"validation","validationCode":"function buildFluxGenerateArgs(input) {\n  if (typeof input.prompt !== 'string' || !input.prompt.trim()) {\n    throw new Error('FluxAPI generate requires a non-empty prompt.');\n  }\n  return { action: 'generate', ...input };\n}","typeGuard":"function hasPrompt(arg) {\n  return typeof arg?.prompt === 'string' && arg.prompt.trim().length > 0;\n}","tryCatchPattern":"try {\n  await fluxTool.invoke(args);\n} catch (e) {\n  if (/Missing required field: prompt/.test(e.message)) return 'A prompt is required to generate.';\n  throw e;\n}","preventionTips":["Require `prompt` in the FluxAPI schema for the generate action.","Default `action` explicitly so an omitted prompt is caught early.","Validate the arg shape at the tool-call boundary."],"tags":["fluxapi","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"}