{"record":{"id":"9f996a26b63fcc31","repo":"n8n-io/n8n","slug":"authentication-failed-during-document-upload-inv","errorCode":null,"errorMessage":"Authentication failed during document upload - invalid API key or endpoint.","messagePattern":"Authentication failed during document upload - invalid API key or endpoint\\.","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreAzureAISearch/VectorStoreAzureAISearch.node.ts","lineNumber":506,"sourceCode":"\t\t\t// Add documents to Azure AI Search (framework handles batching)\n\t\t\tawait vectorStore.addDocuments(transformedDocuments);\n\t\t} catch (error) {\n\t\t\t// Log the full error for debugging\n\t\t\tcontext.logger.debug('Azure AI Search error details:', {\n\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t\tcode: (error as any).code,\n\t\t\t\tstatusCode: (error as any).statusCode,\n\t\t\t\tdetails: (error as any).details,\n\t\t\t\tstack: error instanceof Error ? error.stack : undefined,\n\t\t\t});\n\n\t\t\t// Check for authentication errors\n\t\t\tif (\n\t\t\t\terror.message?.includes('401') ||\n\t\t\t\terror.message?.includes('Unauthorized') ||\n\t\t\t\terror.message?.includes('authentication failed')\n\t\t\t) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tcontext.getNode(),\n\t\t\t\t\t'Authentication failed during document upload - invalid API key or endpoint.',\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'Please verify your API Key and Search Endpoint are correct in the credentials configuration.',\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Check for authorization errors\n\t\t\tif (\n\t\t\t\terror.message?.includes('403') ||\n\t\t\t\terror.message?.includes('Forbidden') ||\n\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(),","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreAzureAISearch/VectorStoreAzureAISearch.node.ts#L488-L524","documentation":"The populateVectorStore (document upload) catch block reclassifies any error whose message contains '401'/'Unauthorized'/'authentication failed' as an authentication NodeOperationError. It is the upload-path counterpart of error 772 — the API key or endpoint was rejected while inserting documents.","triggerScenarios":"An error thrown by vectorStore.addDocuments (or the transform pipeline) whose message includes '401'/'Unauthorized'/'authentication failed'.","commonSituations":"The API key was valid at connection time but revoked/rotated before upload; the endpoint URL is wrong; a different credential got selected; throttling returned a 401-like body.","solutions":["Verify the API key and endpoint in the credential are still valid.","If the key was rotated, update the credential and re-run.","Confirm the same search service/endpoint is used consistently across the run."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await vectorStore.addDocuments(docs);\n} catch (e) {\n  if (/401|Unauthorized|authentication failed/i.test(e.message ?? '')) {\n    // credential likely rotated mid-run; abort and refresh\n  }\n}","preventionTips":["Keep credentials stable for the duration of a long-running ingest job.","Run a pre-flight auth check immediately before large uploads."],"tags":["azure-ai-search","vector-store","authentication","document-upload","http-401"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}