{"record":{"id":"38f1247ef27faac3","repo":"n8n-io/n8n","slug":"api-key-is-required-for-authentication","errorCode":null,"errorMessage":"API Key is required for authentication","messagePattern":"API Key is required for authentication","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreAzureAISearch/VectorStoreAzureAISearch.node.ts","lineNumber":187,"sourceCode":"\tapiKey: string;\n}\n\nasync function getValidatedCredentials(\n\tcontext: IFunctionsContext,\n\titemIndex: number,\n): Promise<ValidatedCredentials> {\n\tconst credentials = await context.getCredentials(AZURE_AI_SEARCH_CREDENTIALS);\n\n\tif (!credentials.endpoint || typeof credentials.endpoint !== 'string') {\n\t\tthrow new NodeOperationError(\n\t\t\tcontext.getNode(),\n\t\t\t'Azure AI Search endpoint is missing or invalid',\n\t\t\t{ itemIndex },\n\t\t);\n\t}\n\n\tif (!credentials.apiKey || typeof credentials.apiKey !== 'string') {\n\t\tthrow new NodeOperationError(context.getNode(), 'API Key is required for authentication', {\n\t\t\titemIndex,\n\t\t});\n\t}\n\n\treturn {\n\t\tendpoint: credentials.endpoint,\n\t\tapiKey: credentials.apiKey,\n\t};\n}\n\n/**\n * Deletes an Azure AI Search index if clearIndex option is enabled.\n * Exported for testing purposes.\n */\nexport async function clearAzureSearchIndex(\n\tcontext: IFunctionsContext,\n\titemIndex: number,\n): Promise<boolean> {","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreAzureAISearch/VectorStoreAzureAISearch.node.ts#L169-L205","documentation":"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.","triggerScenarios":"context.getCredentials(AZURE_AI_SEARCH_CREDENTIALS) returns an object where 'apiKey' is undefined, empty, or not a string.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const cred = await context.getCredentials(AZURE_AI_SEARCH_CREDENTIALS);\nif (typeof cred?.apiKey !== 'string' || cred.apiKey.trim() === '') {\n  throw new Error('Azure AI Search credential is missing an API key.');\n}","typeGuard":"function hasApiKey(c: unknown): c is { apiKey: string } {\n  return typeof c === 'object' && c !== null &&\n    typeof (c as any).apiKey === 'string' && (c as any).apiKey !== '';\n}","tryCatchPattern":null,"preventionTips":["Treat the API key as a required field in the credential form.","After rotating keys in Azure, immediately update the n8n credential."],"tags":["credentials","configuration","azure-ai-search","vector-store","authentication"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}