{"record":{"id":"9e3136640b9b9203","repo":"n8n-io/n8n","slug":"azure-ai-search-api-error-statuscode-error","errorCode":null,"errorMessage":"Azure AI Search API error (${statusCode}): ${errorMessage}","messagePattern":"Azure AI Search API error \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreAzureAISearch/VectorStoreAzureAISearch.node.ts","lineNumber":539,"sourceCode":"\t\t\t\t(error as any).statusCode === 403\n\t\t\t) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tcontext.getNode(),\n\t\t\t\t\t'Authorization failed - insufficient permissions for document upload.',\n\t\t\t\t\t{\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'The API Key does not have sufficient permissions for write operations. Ensure the key has the required access level.',\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Check for RestError (common Azure SDK error)\n\t\t\tif ((error as any).name === 'RestError' || error.message?.includes('RestError')) {\n\t\t\t\tconst statusCode = (error as any).statusCode || 'unknown';\n\t\t\t\tconst errorCode = (error as any).code || 'unknown';\n\t\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tcontext.getNode(),\n\t\t\t\t\t`Azure AI Search API error (${statusCode}): ${errorMessage}`,\n\t\t\t\t\t{\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\tdescription: `Error code: ${errorCode}\\n\\nCommon causes:\\n- Invalid endpoint URL\\n- Index doesn't exist\\n- Authentication/authorization issues\\n- API version mismatch\\n\\nCheck the console logs for detailed error information.`,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\tthrow new NodeOperationError(context.getNode(), `Error: ${errorMessage}`, {\n\t\t\t\titemIndex,\n\t\t\t\tdescription: 'Please check your Azure AI Search connection details and index configuration',\n\t\t\t});\n\t\t}\n\t},\n}) {}\n","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreAzureAISearch/VectorStoreAzureAISearch.node.ts#L521-L557","documentation":"The populateVectorStore catch block handles Azure SDK RestError specially: it surfaces the HTTP statusCode, the SDK error code, and a multi-line description of common causes. RestError is thrown by @azure/core-rest-pipeline when a request fails or has no response.","triggerScenarios":"error.name === 'RestError' OR error.message includes 'RestError' during document upload — e.g. the REST call to Azure AI Search returned a non-2xx status (400 bad request, 404 index missing, 409 conflict, 429 throttled, 5xx).","commonSituations":"Index does not exist; API version mismatch between SDK and service; malformed document fields/vector dimensions; throttling (429); transient 5xx from Azure; wrong endpoint URL.","solutions":["Read the statusCode and error code in the message/description to classify (404=index missing, 400=bad payload, 429=throttle, 5xx=transient).","Ensure the index exists and its vector field dimensions match the embeddings model.","For 429, reduce batch size / add retry with backoff.","Update the @azure/search-documents SDK if there is an API-version mismatch."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"function isRestError(e: unknown): e is { statusCode?: number; code?: string; message: string } {\n  return e instanceof Error && ((e as any).name === 'RestError' || /RestError/i.test(e.message));\n}","tryCatchPattern":"for (const [attempt, delay] of [0, 500, 2000].entries()) {\n  try { await vectorStore.addDocuments(docs); break; }\n  catch (e) {\n    if (isRestError(e) && (e.statusCode === 429 || (e.statusCode ?? 0) >= 500) && attempt < 2) {\n      await sleep(delay); continue;\n    }\n    throw e;\n  }\n}","preventionTips":["Retry with backoff on 429/5xx RestErrors; do not retry 4xx (except 429).","Validate vector dimensions and document shape before upload to avoid 400 RestErrors."],"tags":["azure-ai-search","vector-store","rest-error","document-upload","http-status"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}