n8n-io/n8n · error · NodeOperationError
Authentication failed during document upload - invalid API k
Error message
Authentication failed during document upload - invalid API key or endpoint.
What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreAzureAISearch/VectorStoreAzureAISearch.node.ts:506
// Add documents to Azure AI Search (framework handles batching)
await vectorStore.addDocuments(transformedDocuments);
} catch (error) {
// Log the full error for debugging
context.logger.debug('Azure AI Search error details:', {
message: error instanceof Error ? error.message : String(error),
code: (error as any).code,
statusCode: (error as any).statusCode,
details: (error as any).details,
stack: error instanceof Error ? error.stack : undefined,
});
// Check for authentication errors
if (
error.message?.includes('401') ||
error.message?.includes('Unauthorized') ||
error.message?.includes('authentication failed')
) {
throw new NodeOperationError(
context.getNode(),
'Authentication failed during document upload - invalid API key or endpoint.',
{
itemIndex,
description:
'Please verify your API Key and Search Endpoint are correct in the credentials configuration.',
},
);
}
// Check for authorization errors
if (
error.message?.includes('403') ||
error.message?.includes('Forbidden') ||
(error as any).statusCode === 403
) {
throw new NodeOperationError(
context.getNode(),View on GitHub (pinned to 5ac6606e81)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await vectorStore.addDocuments(docs);
} catch (e) {
if (/401|Unauthorized|authentication failed/i.test(e.message ?? '')) {
// credential likely rotated mid-run; abort and refresh
}
} Prevention
- Keep credentials stable for the duration of a long-running ingest job.
- Run a pre-flight auth check immediately before large uploads.
When it happens
Trigger: An error thrown by vectorStore.addDocuments (or the transform pipeline) whose message includes '401'/'Unauthorized'/'authentication failed'.
Common situations: 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.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Authentication failed - invalid API key or endpoint.
- API Key is required for authentication
- Authorization failed - insufficient permissions for document
- Azure AI Search API error (${statusCode}): ${errorMessage}
- Parameter ${key} must be a string
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/9f996a26b63fcc31.
Report an issue: GitHub.