{"record":{"id":"1ac91a780c02faa7","repo":"Mintplex-Labs/anything-llm","slug":"azure-openai-failed-to-embed-error","errorCode":null,"errorMessage":"Azure OpenAI Failed to embed: ${error}","messagePattern":"Azure OpenAI Failed to embed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/EmbeddingEngines/azureOpenAi/index.js","lineNumber":105,"sourceCode":"        .flat();\n      if (errors.length > 0) {\n        let uniqueErrors = new Set();\n        errors.map((error) =>\n          uniqueErrors.add(`[${error.type}]: ${error.message}`)\n        );\n\n        return {\n          data: [],\n          error: Array.from(uniqueErrors).join(\", \"),\n        };\n      }\n      return {\n        data: results.map((res) => res?.data || []).flat(),\n        error: null,\n      };\n    });\n\n    if (!!error) throw new Error(`Azure OpenAI Failed to embed: ${error}`);\n    return data.length > 0 &&\n      data.every((embd) => embd.hasOwnProperty(\"embedding\"))\n      ? data.map((embd) => embd.embedding)\n      : null;\n  }\n}\n\nmodule.exports = {\n  AzureOpenAiEmbedder,\n};\n","sourceCodeStart":87,"sourceCodeEnd":116,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/azureOpenAi/index.js#L87-L116","documentation":"Thrown after all concurrent embedding batch requests settle, when at least one batch returned an error. Per-batch errors are collected into a uniqueErrors set and joined into a single comma-separated message prefixed 'Azure OpenAI Failed to embed:'. If any batch fails the entire embedChunks call aborts and returns no vectors.","triggerScenarios":"Wrong deployment name in EMBEDDING_MODEL_PREF (resource has no such deployment); 401 expired AZURE_OPENAI_KEY mid-run; 429 token-per-minute rate limits on large batches; input text exceeding the model's token limit; content filter rejecting a chunk; partial network failures hitting some concurrent batches.","commonSituations":"Embedding a large document set that spikes TPM and rate-limits several batches; a single oversized chunk; deployment deleted/renamed in Azure; key revoked between batches; content-policy blocks on certain text.","solutions":["Read the joined message: 'deployment not found' -> fix EMBEDDING_MODEL_PREF; '401'/'Unauthorized' -> rotate key; '429' -> reduce maxConcurrentChunks or batch size; content_filter -> clean input.","Lower concurrency or chunk size to stay under Azure tokens-per-minute.","Retry the embed call after fixing the persistent error; partial success is not returned, so all chunks must re-run.","Verify the deployment name matches the Azure resource exactly (case-sensitive)."],"exampleFix":"// before\nif (!!error) throw new Error(`Azure OpenAI Failed to embed: ${error}`);\n\n// after (continue on partial, report missing indices)\nif (!!error) {\n  console.warn(`Azure embed partial failure: ${error}`);\n}\nreturn data.length > 0 && data.every((e) => e?.hasOwnProperty(\"embedding\"))\n  ? data.map((e) => e.embedding)\n  : null;","handlingStrategy":"try-catch","validationCode":"// Pre-flight a single tiny embed to validate deployment + key before bulk runs\ntry {\n  await embedder.embedTextInput('ping');\n} catch (e) {\n  throw new Error(`Azure embed preflight failed: ${e.message}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await embedder.embedChunks(chunks);\n} catch (e) {\n  const msg = e.message;\n  if (/deployment|not found/i.test(msg)) handleBadDeployment();\n  else if (/401|unauthorized/i.test(msg)) rotateKey();\n  else if (/429|rate/i.test(msg)) reduceConcurrency();\n  else if (/content/i.test(msg)) sanitizeInput();\n  else throw e;\n}","preventionTips":["Pre-flight with a single small embed before bulk runs.","Size batches to stay under Azure tokens-per-minute.","Confirm the deployment name matches the resource exactly."],"tags":["azure","openai","embeddings","rate-limit","content-filter","batch"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}