diff --git a/docker/lib/dependabot/docker/update_checker.rb b/docker/lib/dependabot/docker/update_checker.rb index d46ec4ecdc9..f087d70ef35 100644 --- a/docker/lib/dependabot/docker/update_checker.rb +++ b/docker/lib/dependabot/docker/update_checker.rb @@ -233,6 +233,8 @@ def tags_from_registry retry end + rescue DockerRegistry2::NotFound + raise DockerRegistry2::NotFound, "Image not found: https://#{registry_hostname}/#{docker_repo_name}" rescue DockerRegistry2::RegistryAuthenticationException, RestClient::Forbidden raise PrivateSourceAuthenticationFailure, registry_hostname diff --git a/docker/spec/dependabot/docker/update_checker_spec.rb b/docker/spec/dependabot/docker/update_checker_spec.rb index 582efd9997d..adddbf847d5 100644 --- a/docker/spec/dependabot/docker/update_checker_spec.rb +++ b/docker/spec/dependabot/docker/update_checker_spec.rb @@ -283,6 +283,44 @@ it { is_expected.to eq("17.04") } end + context "when image is not found" do + let(:tags_fixture_name) { "ubuntu_no_latest.json" } + + context "with replaces-base set to true" do + let(:credentials) do + [{ + "type" => "git_source", + "host" => "github.com", + "username" => "x-access-token", + "password" => "token" + }, { + "type" => "docker_registry", + "registry" => "registry-host.io:5000", + "username" => "grey", + "password" => "pa55word", + "replaces-base" => true + }] + end + + before do + tags_url = "https://registry-host.io:5000/v2/ubuntu/tags/list" + stub_request(:get, tags_url). + and_return( + status: 404, + body: "" + ) + end + + it "raises a to DockerRegistry2::NotFound error" do + error_class = DockerRegistry2::NotFound + expect { checker.latest_version }. + to raise_error(error_class) do |error| + expect(error.message).to eq("Image not found: https://registry-host.io:5000/ubuntu") + end + end + end + end + context "when the dependency's version has a prefix" do let(:version) { "artful-20170826" } it { is_expected.to eq("artful-20170916") }