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
- Open the Azure AI Search credential and paste a valid admin or query key from the Azure portal.
- If the key was rotated in Azure, copy the new key into the credential.
- 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
- Treat the API key as a required field in the credential form.
- After rotating keys in Azure, immediately update the n8n credential.
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
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Azure AI Search endpoint is missing or invalid
- No authentication data defined on node!
- Index ${credentials.pineconeIndex} not found
- Authentication failed - invalid API key or endpoint.
- Error: ${errorMessage}
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/38f1247ef27faac3.
Report an issue: GitHub.