summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-01-15 07:55:51 +0000
committerColby Swandale <me@colby.fyi>2019-04-04 22:23:01 +1100
commit0e11bce635045ba967f9223ccba5ea66725b8296 (patch)
tree12f0f51af5a5b896d9673f2c82e40c7a796595d8
parentaa1569fceaa31992f3e931ca56d5ea4d10a3a346 (diff)
downloadbundler-0e11bce635045ba967f9223ccba5ea66725b8296.tar.gz
Merge #6864
6864: Include URL in Bundler::Fetcher::FallbackError message for Net::HTTPNotFound r=segiddins a=greysteil ### What was the end-user problem that led to this PR? It was really painful to debug persistent NotFound errors, as it wasn't clear where they were coming from, ### What was your diagnosis of the problem? Bundler was obfuscating the URL that wasn't found unnecessarily. ### What is your fix for the problem, implemented in this PR? My fix is to add the URL to the `Bundler::Fetcher::FallbackError` message for `Net::HTTPNotFound` errors. ### Why did you choose this fix out of the possible options? I chose this fix because it was simple and easy to test. Co-authored-by: Grey Baker <greysteil@gmail.com> (cherry picked from commit 4557124b5ea30821895eb2686874cb4219f404e2)
-rw-r--r--lib/bundler/fetcher/downloader.rb2
-rw-r--r--spec/bundler/fetcher/downloader_spec.rb12
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb
index e0e0cbf1c9..87ad4140fd 100644
--- a/lib/bundler/fetcher/downloader.rb
+++ b/lib/bundler/fetcher/downloader.rb
@@ -37,7 +37,7 @@ module Bundler
when Net::HTTPUnauthorized
raise AuthenticationRequiredError, uri.host
when Net::HTTPNotFound
- raise FallbackError, "Net::HTTPNotFound"
+ raise FallbackError, "Net::HTTPNotFound: #{URICredentialsFilter.credential_filtered_uri(uri)}"
else
raise HTTPError, "#{response.class}#{": #{response.body}" unless response.body.empty?}"
end
diff --git a/spec/bundler/fetcher/downloader_spec.rb b/spec/bundler/fetcher/downloader_spec.rb
index c9b4fa662a..07b507266b 100644
--- a/spec/bundler/fetcher/downloader_spec.rb
+++ b/spec/bundler/fetcher/downloader_spec.rb
@@ -88,7 +88,17 @@ RSpec.describe Bundler::Fetcher::Downloader do
let(:http_response) { Net::HTTPNotFound.new("1.1", 404, "Not Found") }
it "should raise a Bundler::Fetcher::FallbackError with Net::HTTPNotFound" do
- expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::Fetcher::FallbackError, "Net::HTTPNotFound")
+ expect { subject.fetch(uri, options, counter) }.
+ to raise_error(Bundler::Fetcher::FallbackError, "Net::HTTPNotFound: http://www.uri-to-fetch.com/api/v2/endpoint")
+ end
+
+ context "when the there are credentials provided in the request" do
+ let(:uri) { URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") }
+
+ it "should raise a Bundler::Fetcher::FallbackError that doesn't contain the password" do
+ expect { subject.fetch(uri, options, counter) }.
+ to raise_error(Bundler::Fetcher::FallbackError, "Net::HTTPNotFound: http://username@www.uri-to-fetch.com/api/v2/endpoint")
+ end
end
end