{"record":{"id":"07d33c8c7b7ef476","repo":"n8n-io/n8n","slug":"invalid-authentication-method","errorCode":null,"errorMessage":"Invalid authentication method","messagePattern":"Invalid authentication method","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.ts","lineNumber":98,"sourceCode":"\t\t\t\titemIndex,\n\t\t\t) as AuthenticationType;\n\t\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as AzureOpenAIOptions;\n\n\t\t\t// Set up Authentication based on selection and get configuration\n\t\t\tlet modelConfig: AzureOpenAIApiKeyModelConfig | AzureOpenAIOAuth2ModelConfig;\n\t\t\tswitch (authenticationMethod) {\n\t\t\t\tcase AuthenticationType.ApiKey:\n\t\t\t\t\tmodelConfig = await setupApiKeyAuthentication.call(this, 'azureOpenAiApi');\n\t\t\t\t\tbreak;\n\t\t\t\tcase AuthenticationType.EntraOAuth2:\n\t\t\t\t\tmodelConfig = await setupOAuth2Authentication.call(\n\t\t\t\t\t\tthis,\n\t\t\t\t\t\t'azureEntraCognitiveServicesOAuth2Api',\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new NodeOperationError(this.getNode(), 'Invalid authentication method');\n\t\t\t}\n\n\t\t\tthis.logger.info(`Instantiating AzureChatOpenAI model with deployment: ${modelName}`);\n\n\t\t\tconst timeout = options.timeout;\n\t\t\tconst model = new AzureChatOpenAI({\n\t\t\t\t// Force completions API — Azure's SDK doesn't rewrite the /responses path,\n\t\t\t\t// so the Responses API hits an invalid endpoint and causes a connection error.\n\t\t\t\t// See: https://github.com/langchain-ai/langchainjs/issues/9038\n\t\t\t\tuseResponsesApi: false,\n\t\t\t\t// Model name is required so logs are correct\n\t\t\t\t// Also ensures internal logic (like mapping \"maxTokens\" to \"maxCompletionTokens\") is correct\n\t\t\t\tmodel: modelName,\n\t\t\t\tazureOpenAIApiDeploymentName: modelName,\n\t\t\t\t...modelConfig,\n\t\t\t\t...options,\n\t\t\t\ttimeout,\n\t\t\t\tmaxRetries: options.maxRetries ?? 2,","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.ts#L80-L116","documentation":"The default branch of a switch on authenticationMethod in the Azure OpenAI Chat node. The switch only handles AuthenticationType.ApiKey and AuthenticationType.EntraOAuth2; any other value (or an unknown future auth type) hits the default and throws NodeOperationError before the client is built.","triggerScenarios":"authenticationMethod parameter holds a value outside {apiKey, entraOAuth2} — e.g. from a hand-edited workflow JSON, a stale value from a deprecated auth type, or a forward-incompatible enum.","commonSituations":"Importing an older workflow that used a removed auth method; manually editing the workflow JSON; future n8n version adding a new auth type that the current code doesn't handle; corrupted credential parameter.","solutions":["Open the node credential selector and re-pick 'API Key' or 'Entra ID (OAuth2)'.","Recreate the credential if the dropdown does not show a valid selection.","Upgrade n8n / nodes-langchain so the auth type enum matches the code's switch arms."],"exampleFix":"// before\nauthenticationMethod === 'azureActiveDirectory' // no longer handled\n// after\nauthenticationMethod === 'entraOAuth2'","handlingStrategy":"type-guard","validationCode":"const ALLOWED = [AuthenticationType.ApiKey, AuthenticationType.EntraOAuth2];\nif (!ALLOWED.includes(authenticationMethod)) {\n  throw new Error(`Pick 'API Key' or 'Entra ID (OAuth2)' in the credential selector.`);\n}","typeGuard":"const isSupportedAuth = (m: unknown): m is AuthenticationType =>\n  m === AuthenticationType.ApiKey || m === AuthenticationType.EntraOAuth2;","tryCatchPattern":"// Validate the enum at node-save time; surface allowed values.","preventionTips":["Always use the dropdown for authentication method.","Recreate the node/credential if importing a deprecated auth type.","Upgrade nodes-langchain to keep the enum and switch arms aligned."],"tags":["azure","openai","llm","authentication","configuration"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}