{"record":{"id":"641f4b1f225e646d","repo":"Mintplex-Labs/anything-llm","slug":"lemonade-failed-to-embed-error-type-error","errorCode":null,"errorMessage":"Lemonade Failed to embed: [${error.type}]: ${error.message}","messagePattern":"Lemonade Failed to embed: \\[(.+?)\\]: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/EmbeddingEngines/lemonade/index.js","lineNumber":81,"sourceCode":"              });\n              return;\n            }\n            resolve({ data: result?.data, error: null });\n          })\n          .catch((e) => {\n            e.type =\n              e?.response?.data?.error?.code ||\n              e?.response?.status ||\n              \"failed_to_embed\";\n            e.message = e?.response?.data?.error?.message || e.message;\n            resolve({ data: [], error: e });\n          });\n      });\n\n      if (error) {\n        const errorMsg = `Lemonade Failed to embed: [${error.type}]: ${error.message}`;\n        this.log(errorMsg);\n        throw new Error(errorMsg);\n      }\n      allResults.push(...(data || []));\n      reportEmbeddingProgress(\n        Math.min(allResults.length, textChunks.length),\n        textChunks.length\n      );\n    }\n\n    return allResults.length > 0 &&\n      allResults.every((embd) => embd.hasOwnProperty(\"embedding\"))\n      ? allResults.map((embd) => embd.embedding)\n      : null;\n  }\n}\n\nmodule.exports = {\n  LemonadeEmbedder,\n};","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/lemonade/index.js#L63-L99","documentation":"Thrown inside the embedChunks loop when a batch resolves with an error (either a result.error payload or a rejected promise). The message is formatted 'Lemonade Failed to embed: [<type>]: <message>' where type defaults to 'failed_to_embed' (or the HTTP status) and message defaults to the upstream error text. The loop logs the message then throws on the first failing batch.","triggerScenarios":"EMBEDDING_MODEL_PREF names a model not loaded in the Lemonade server; the Lemonade server is down/unreachable mid-run; LEMONADE_LLM_API_KEY required but unset/invalid; chunks exceed the model's capacity; the server returns a non-2xx with an error body.","commonSituations":"Local Lemonade server restarted without reloading the embedding model; wrong model id; resource limits on the GPU causing failures on large batches; auth enabled on the server but key unset.","solutions":["Read [<type>]: <message>: 'failed_to_embed' with a status -> inspect the Lemonade server logs; 'model not found' -> fix EMBEDDING_MODEL_PREF / load the model; auth errors -> set LEMONADE_LLM_API_KEY.","Confirm the Lemonade server is up at the parsed endpoint and the model is loaded (hit its /v1/models equivalent).","Reduce maxConcurrentChunks (default 50) and chunk size to fit local hardware limits.","Restart the Lemonade server and retry once it is healthy; partial vectors are not returned."],"exampleFix":"// before\nif (error) {\n  const errorMsg = `Lemonade Failed to embed: [${error.type}]: ${error.message}`;\n  this.log(errorMsg);\n  throw new Error(errorMsg);\n}\n\n// after (collect per-batch failures, continue best-effort)\nif (error) {\n  this.log(`Lemonade batch failed: [${error.type}]: ${error.message}`);\n  failedBatches.push(chunk);\n  continue;\n}","handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm Lemonade exposes the embedding model before bulk\nconst { OpenAI } = require('openai');\nconst { parseLemonadeServerEndpoint } = require('../../AiProviders/lemonade');\nconst client = new OpenAI({ baseURL: parseLemonadeServerEndpoint(process.env.EMBEDDING_BASE_PATH, 'openai'), apiKey: process.env.LEMONADE_LLM_API_KEY || null });\nconst list = await client.models.list();\nif (!list.body.some((m) => m.id === process.env.EMBEDDING_MODEL_PREF)) {\n  throw new Error(`Lemonade does not expose model ${process.env.EMBEDDING_MODEL_PREF}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await embedder.embedChunks(chunks);\n} catch (e) {\n  const msg = e.message;\n  if (/model.*not|404|not.found/i.test(msg)) loadModel();\n  else if (/unauthorized|401/i.test(msg)) setApiKey();\n  else if (/econnrefused|timeout|socket/i.test(msg)) waitForServer();\n  else throw e;\n}","preventionTips":["Pre-flight models.list() against the parsed Lemonade endpoint before bulk runs.","Keep the embedding model loaded in the Lemonade server; reload after restarts.","Reduce maxConcurrentChunks (default 50) to fit local hardware limits."],"tags":["lemonade","amd","embeddings","local-llm","batch","network"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}