{"record":{"id":"c10f27f0145c4ba8","repo":"puppetlabs/puppet","slug":"too-many-http-redirections-for-addr","errorCode":null,"errorMessage":"Too many HTTP redirections for %{addr}","messagePattern":"Too many HTTP redirections for %(.+?)","errorType":"exception","errorClass":"Puppet::HTTP::TooManyRedirects","httpStatus":null,"severity":"error","filePath":"lib/puppet/http/redirector.rb","lineNumber":46,"sourceCode":"    when 301, 302, 307\n      true\n    else\n      false\n    end\n  end\n\n  # Implement the HTTP request redirection\n  #\n  # @param [Net::HTTP] request request that has been redirected\n  # @param [Puppet::HTTP::Response] response\n  # @param [Integer] redirects the current number of redirects\n  #\n  # @return [Net::HTTP] A new request based on the original request, but with\n  #   the redirected location\n  #\n  # @api private\n  def redirect_to(request, response, redirects)\n    raise Puppet::HTTP::TooManyRedirects, request.uri if redirects >= @redirect_limit\n\n    location = parse_location(response)\n    url = request.uri.merge(location)\n\n    new_request = request.class.new(url)\n    new_request.body = request.body\n    request.each do |header, value|\n      unless Puppet[:location_trusted]\n        # skip adding potentially sensitive header to other hosts\n        next if header.casecmp('Authorization').zero? && request.uri.host.casecmp(location.host) != 0\n        next if header.casecmp('Cookie').zero? && request.uri.host.casecmp(location.host) != 0\n      end\n      # Allow Net::HTTP to set its own Accept-Encoding header to avoid errors with HTTP compression.\n      # See https://github.com/puppetlabs/puppet/issues/9143\n      next if header.casecmp('Accept-Encoding').zero?\n\n      new_request[header] = value\n    end","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/http/redirector.rb#L28-L64","documentation":"Puppet::HTTP::Client follows 301/302/307 redirects through Puppet::HTTP::Redirector, counting each hop. When the hop count reaches the redirect limit — default 10, overridable per request via options[:redirect_limit] (client.rb:354) — it raises Puppet::HTTP::TooManyRedirects with the request URI in the message. This indicates a chain longer than allowed or a redirect loop.","triggerScenarios":"A redirect chain (A→B→C…) longer than redirect_limit; a loop such as https→https rewrites where hostnames alternate; a proxy redirecting to itself; count reaches the limit on the next redirect_to call because redirects >= @redirect_limit.","commonSituations":"Misconfigured reverse proxy or SSL terminator rewriting in a circle; CDN/LB redirect rules that drop the port; server_list entries pointing at a vhost that redirects to a login page that redirects back; captive portals.","solutions":["Reproduce with curl -ILv <url> and count the hops: fix the server-side rewrite loop first.","Ensure redirect targets are final URLs (correct scheme/host/port) rather than re-entering the redirect rule.","If the chain is legitimately longer than 10, raise options[:redirect_limit] on the specific request instead of globally.","Check proxy PreserveHost/redirect rules when a load balancer sits in front of the compiler/CA."],"exampleFix":"# before\nresponse = client.get(uri)\n\n# after - allow a longer (but still bounded) chain for this request\nresponse = client.get(uri, options: { redirect_limit: 20 })","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"begin\n  response = client.get(uri)\nrescue Puppet::HTTP::TooManyRedirects => e\n  # e.message includes the original request URI\n  Puppet.err \"redirect budget exhausted for #{uri}; verify server/proxy rewrites\"\n  raise\nend","preventionTips":["Verify redirect chains with curl -IL before pointing puppet at a URL.","Keep the default redirect_limit of 10; fix loops server-side instead of raising it.","Configure proxies with final target URLs (correct scheme/host/port) to avoid re-entry."],"tags":["puppet","http","redirect","redirect-loop","network"],"backgroundTag":"too-many-redirects","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}