Skip to content

Commit

Permalink
handler for error response from docker image tag fetch (#11594)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin-sandhu authored Feb 14, 2025
1 parent 5fb726b commit ad09d59
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docker/lib/dependabot/docker/update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ def tags_from_registry
rescue RestClient::ServerBrokeConnection,
RestClient::TooManyRequests
raise PrivateSourceBadResponse, registry_hostname
rescue JSON::ParserError => e
if e.message.include?("unexpected token")
raise DependencyFileNotResolvable, "Error while accessing docker image at #{registry_hostname}"
end

raise
end

sig { returns(T.nilable(String)) }
Expand Down
12 changes: 12 additions & 0 deletions docker/spec/dependabot/docker/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,18 @@ def stub_tag_with_no_digest(tag)
end
end

context "when there is ParserError response from while accessing docker image tags" do
before do
stub_request(:get, repo_url + "tags/list")
.to_raise(JSON::ParserError.new("unexpected token"))
end

it "raises" do
expect { checker.latest_version }
.to raise_error(Dependabot::DependencyFileNotResolvable)
end
end

context "when TooManyRequests request error" do
before do
stub_request(:get, repo_url + "tags/list")
Expand Down

0 comments on commit ad09d59

Please sign in to comment.