{"record":{"id":"be099cdb4074299d","repo":"ruby/rubygems","slug":"server-did-not-return-a-valid-file","errorCode":null,"errorMessage":"server did not return a valid file","messagePattern":"server did not return a valid file","errorType":"exception","errorClass":"Gem::RemoteFetcher::FetchError","httpStatus":null,"severity":"error","filePath":"lib/rubygems/remote_fetcher.rb","lineNumber":267,"sourceCode":"  # 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\n    method = {\n      \"http\" => \"fetch_http\",\n      \"https\" => \"fetch_http\",\n      \"s3\" => \"fetch_s3\",\n      \"file\" => \"fetch_file\",\n    }.fetch(uri.scheme) { raise ArgumentError, \"uri scheme is invalid: #{uri.scheme.inspect}\" }\n\n    data = send method, uri, mtime, head\n\n    if data && !head && uri.to_s.end_with?(\".gz\")\n      begin\n        data = Gem::Util.gunzip data\n      rescue Zlib::GzipFile::Error\n        raise FetchError.new(\"server did not return a valid file\", uri)\n      end\n    end\n\n    data\n  rescue Gem::Timeout::Error, IOError, SocketError, SystemCallError,\n         *(OpenSSL::SSL::SSLError if Gem::HAVE_OPENSSL) => e\n    raise FetchError.new(\"#{e.class}: #{e}\", uri)\n  end\n\n  def fetch_s3(uri, mtime = nil, head = false)\n    begin\n      public_uri = s3_uri_signer(uri, head ? \"HEAD\" : \"GET\").sign\n    rescue Gem::S3URISigner::ConfigurationError, Gem::S3URISigner::InstanceProfileError => e\n      raise FetchError.new(e.message, \"s3://#{uri.host}\")\n    end\n    fetch_https public_uri, mtime, head\n  end\n","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/rubygems/remote_fetcher.rb#L249-L285","documentation":"Error \"server did not return a valid file\" thrown in ruby/rubygems.","triggerScenarios":"Thrown at lib/rubygems/remote_fetcher.rb:267 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-fetch from the source; the response was not a valid gem/spec file","Check that the URL actually serves gems (not an HTML error page)"],"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"}