Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes [weekly 1.5k] [pip] missing key authority error issues #11305

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class FileUpdater
class RequirementReplacer
PACKAGE_NOT_FOUND_ERROR = "PackageNotFoundError"

CERTIFICATE_VERIFY_FAILED = /CERTIFICATE_VERIFY_FAILED/

def initialize(content:, dependency_name:, old_requirement:,
new_requirement:, new_hash_version: nil, index_urls: nil)
@content = content
Expand Down Expand Up @@ -153,6 +155,8 @@ def package_hashes_for(name:, version:, algorithm:)
args: args
)
rescue SharedHelpers::HelperSubprocessFailed => e
requirement_error_handler(e)

raise unless e.message.include?("PackageNotFoundError")

next
Expand Down Expand Up @@ -193,6 +197,17 @@ def requirements_match(req1, req2)
req1&.split(",")&.map { |r| r.gsub(/\s/, "") }&.sort ==
req2&.split(",")&.map { |r| r.gsub(/\s/, "") }&.sort
end

public

def requirement_error_handler(error)
Dependabot.logger.warn(error.message)

return unless error.message.match?(CERTIFICATE_VERIFY_FAILED)

msg = "Error resolving dependency."
raise DependencyFileNotResolvable, msg
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@
it { is_expected.to include("Flask-SQLAlchemy\n") }
it { is_expected.to include("zope.SQLAlchemy\n") }
end

context "when requirement check returns unexpected exception" do
subject(:req_replacer) { replacer.requirement_error_handler(exception) }

let(:exception) { Exception.new(response) }

context "with a registry that results in failed certificate error" do
let(:response) { "CERTIFICATE_VERIFY_FAILED" }

it "raises a helpful error" do
expect { req_replacer }.to raise_error(Dependabot::DependencyFileNotResolvable)
end
end
end
end
end
end
Loading