{"record":{"id":"972973f6d083f24c","repo":"Mintplex-Labs/anything-llm","slug":"image-edit-returned-no-image-data","errorCode":null,"errorMessage":"Image edit returned no image data.","messagePattern":"Image edit returned no image data\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/ImageGenerators/base.js","lineNumber":106,"sourceCode":"    if (!res.ok) {\n      const body = await res.text().catch(() => \"\");\n      throw new Error(\n        `Image edit failed (${res.status}): ${body || res.statusText}`\n      );\n    }\n\n    const payload = await res.json();\n    const image = payload?.data?.[0];\n    let result;\n    if (image?.b64_json) {\n      result = { buffer: Buffer.from(image.b64_json, \"base64\") };\n    } else if (image?.url) {\n      const imgRes = await fetch(image.url, { signal: signal ?? null });\n      if (!imgRes.ok)\n        throw new Error(`Failed to fetch edited image: ${imgRes.status}`);\n      result = { buffer: Buffer.from(await imgRes.arrayBuffer()) };\n    } else {\n      throw new Error(\"Image edit returned no image data.\");\n    }\n    this._sendImageTelemetry(\"image_generated\", {\n      withReferences: images.length > 0,\n    });\n    return result;\n  }\n\n  /**\n   * Emits a telemetry event if Telemetry is turned on.\n   * @param {string} event\n   * @param {Object} [additionalOpts]\n   */\n  _sendImageTelemetry(event, additionalOpts = {}) {\n    const { Telemetry } = require(\"../../models/telemetry\");\n    Telemetry.sendTelemetry(event, {\n      ...additionalOpts,\n      provider: this.className,\n      model: this.model,","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/f92433b4ea0598492a1e6645ea22addbb4dd1287/server/utils/ImageGenerators/base.js#L88-L124","documentation":"The /v1/images/edits call returned 2xx, but payload.data[0] contained neither b64_json nor url — the only two response shapes editImage() understands. The provider 'succeeded' without returning an image, meaning its response envelope is not OpenAI-compatible or the image field is genuinely absent.","triggerScenarios":"An OpenAI-compatible server that returns a different envelope (image nested elsewhere, base64 under a different key, or an empty data array); a provider returning an error body with HTTP 200; a proxy rewriting the response body; a model that returns metadata/text instead of image data.","commonSituations":"Self-hosted OpenAI-compatible image servers (comfyui bridges, local gateways) with nonstandard schemas; providers that change their response format between versions.","solutions":["Log the raw response body before parsing to see what the provider actually returned.","Fix or configure the provider to return OpenAI's shape: data[0].b64_json or data[0].url.","If the provider cannot comply, switch to a different image engine for edits.","Check the provider's own logs to confirm an image was really generated."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isUsableImageEditPayload(payload) {\n  const image = payload?.data?.[0];\n  return Boolean(\n    image &&\n      ((typeof image.b64_json === \"string\" && image.b64_json.length > 0) ||\n        (typeof image.url === \"string\" && image.url.length > 0))\n  );\n}","tryCatchPattern":"try {\n  const image = await generator.editImage({ prompt, images, size, signal });\n} catch (err) {\n  if (err.message === \"Image edit returned no image data.\") {\n    // provider 2xx'd without an OpenAI-shaped body:\n    // log the raw exchange and verify the provider's response schema\n  } else {\n    throw err;\n  }\n}","preventionTips":["Smoke-test a provider's /v1/images/edits response shape before making it selectable.","Log raw edit responses in debug mode to catch envelope drift early.","Prefer providers that return b64_json to avoid schema variance."],"tags":["image-generation","image-edit","empty-response","response-shape"],"backgroundTag":"empty-api-response","analyzedSha":"f92433b4ea0598492a1e6645ea22addbb4dd1287","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}