n8n-io/n8n · error · NodeOperationError

API Key is required for authentication

Error message

API Key is required for authentication

What it means

getValidatedCredentials throws this NodeOperationError when the Azure AI Search credential's 'apiKey' field is missing or not a string. Azure AI Search requires an admin or query key for every request.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreAzureAISearch/VectorStoreAzureAISearch.node.ts:187

	apiKey: string;
}

async function getValidatedCredentials(
	context: IFunctionsContext,
	itemIndex: number,
): Promise<ValidatedCredentials> {
	const credentials = await context.getCredentials(AZURE_AI_SEARCH_CREDENTIALS);

	if (!credentials.endpoint || typeof credentials.endpoint !== 'string') {
		throw new NodeOperationError(
			context.getNode(),
			'Azure AI Search endpoint is missing or invalid',
			{ itemIndex },
		);
	}

	if (!credentials.apiKey || typeof credentials.apiKey !== 'string') {
		throw new NodeOperationError(context.getNode(), 'API Key is required for authentication', {
			itemIndex,
		});
	}

	return {
		endpoint: credentials.endpoint,
		apiKey: credentials.apiKey,
	};
}

/**
 * Deletes an Azure AI Search index if clearIndex option is enabled.
 * Exported for testing purposes.
 */
export async function clearAzureSearchIndex(
	context: IFunctionsContext,
	itemIndex: number,
): Promise<boolean> {

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Open the Azure AI Search credential and paste a valid admin or query key from the Azure portal.
  2. If the key was rotated in Azure, copy the new key into the credential.
  3. Re-select the credential in the node after saving.
Defensive patterns

Strategy: validation

Validate before calling

const cred = await context.getCredentials(AZURE_AI_SEARCH_CREDENTIALS);
if (typeof cred?.apiKey !== 'string' || cred.apiKey.trim() === '') {
  throw new Error('Azure AI Search credential is missing an API key.');
}

Type guard

function hasApiKey(c: unknown): c is { apiKey: string } {
  return typeof c === 'object' && c !== null &&
    typeof (c as any).apiKey === 'string' && (c as any).apiKey !== '';
}

Prevention

When it happens

Trigger: context.getCredentials(AZURE_AI_SEARCH_CREDENTIALS) returns an object where 'apiKey' is undefined, empty, or not a string.

Common situations: The credential's API key field was left blank; the key was rotated in Azure and the credential not updated; the credential was saved in an incomplete state.

Understand the failure class

Related errors


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