{"record":{"id":"8219ad66bdd03020","repo":"ruby/rubygems","slug":"redirecting-to-non-https-resource-location","errorCode":null,"errorMessage":"redirecting to non-https resource: #{location}","messagePattern":"redirecting to non-https resource: #(.+?)","errorType":"exception","errorClass":"Gem::RemoteFetcher::FetchError","httpStatus":null,"severity":"error","filePath":"lib/rubygems/remote_fetcher.rb","lineNumber":235,"sourceCode":"    response   = request uri, fetch_type, last_modified do |req|\n      headers.each {|k,v| req.add_field(k,v) }\n    end\n\n    case response\n    when Gem::Net::HTTPOK, Gem::Net::HTTPNotModified then\n      response.uri = uri\n      head ? response : response.body\n    when Gem::Net::HTTPMovedPermanently, Gem::Net::HTTPFound, Gem::Net::HTTPSeeOther,\n         Gem::Net::HTTPTemporaryRedirect then\n      raise FetchError.new(\"too many redirects\", uri) if depth > 10\n\n      unless location = response[\"Location\"]\n        raise FetchError.new(\"redirecting but no redirect location was given\", uri)\n      end\n      location = Gem::Uri.new location\n\n      if https?(uri) && !https?(location)\n        raise FetchError.new(\"redirecting to non-https resource: #{location}\", uri)\n      end\n\n      fetch_http(location, last_modified, head, depth + 1)\n    else\n      custom_error = response[\"X-Error-Message\"]\n      error_detail = custom_error || response.message\n      raise FetchError.new(\"Bad response #{error_detail} #{response.code}\", uri)\n    end\n  end\n\n  alias_method :fetch_https, :fetch_http\n\n  ##\n  # Downloads +uri+ and returns it as a String.\n\n  def fetch_path(uri, mtime = nil, head = false)\n    uri = Gem::Uri.new uri\n","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/rubygems/remote_fetcher.rb#L217-L253","documentation":"Error \"redirecting to non-https resource: #{location}\" thrown in ruby/rubygems.","triggerScenarios":"Thrown at lib/rubygems/remote_fetcher.rb:235 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an https:// gem source; RubyGems refuses redirects to plain http","Update the source URL in your Gemfile/.gemrc to the https endpoint"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"86cbb817a38ce8477b181c17467a703ded3f2be8","analyzedAt":"2026-08-23T06:27:48.159Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}