{"record":{"id":"11cb3cd864a60ab9","repo":"n8n-io/n8n","slug":"too-many-redirects-max-maxredirects","errorCode":null,"errorMessage":"Too many redirects (max ${maxRedirects})","messagePattern":"Too many redirects \\(max (.+?)\\)","errorType":"exception","errorClass":"OperationalError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/ai-utilities/src/utils/follow-redirects.ts","lineNumber":48,"sourceCode":"\t\t}\n\n\t\tconst response = await fetcher(currentInput, {\n\t\t\t...currentInit,\n\t\t\tredirect: 'manual',\n\t\t});\n\n\t\tif (response.status < 300 || response.status >= 400) {\n\t\t\treturn response;\n\t\t}\n\n\t\tconst location = response.headers.get('location');\n\t\tif (!location) {\n\t\t\treturn response;\n\t\t}\n\n\t\thops += 1;\n\t\tif (hops > maxRedirects) {\n\t\t\tthrow new OperationalError(`Too many redirects (max ${maxRedirects})`);\n\t\t}\n\n\t\tawait response.body?.cancel().catch(() => {});\n\n\t\tcurrentInput = new URL(location, currentUrlString);\n\n\t\tconst method = (currentInit.method ?? 'GET').toUpperCase();\n\t\tconst isUnsafe = method !== 'GET' && method !== 'HEAD';\n\t\tif (\n\t\t\tresponse.status === 303 ||\n\t\t\t((response.status === 301 || response.status === 302) && isUnsafe)\n\t\t) {\n\t\t\tcurrentInit = { ...currentInit, method: 'GET', body: undefined };\n\t\t}\n\t}\n}\n","sourceCodeStart":30,"sourceCodeEnd":65,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/ai-utilities/src/utils/follow-redirects.ts#L30-L65","documentation":"OperationalError from fetchFollowingRedirects when the HTTP response chain exceeds maxRedirects 3xx hops. It fires after each redirect is followed manually with redirect:'manual' and the hop counter passes the limit — usually a redirect loop or an unusually long chain. Signals the request was abandoned before a final response was reached.","triggerScenarios":"Thrown at packages/@n8n/ai-utilities/src/utils/follow-redirects.ts:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase maxRedirects if the target legitimately needs more hops.","Fix the redirect loop: a URL that redirects to itself or cycles between URLs will always exhaust the limit.","If the endpoint must not be followed past the limit, handle the 3xx response manually instead of calling fetchFollowingRedirects."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","contentChangedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}