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

  1. Verify the API key and endpoint in the credential are still valid.
  2. If the key was rotated, update the credential and re-run.
  3. 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

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

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/9f996a26b63fcc31. Report an issue: GitHub.