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.3k] [docker] RestClient::ServerBrokeConnection and related errors #11456

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
33 changes: 33 additions & 0 deletions common/lib/dependabot/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require "sorbet-runtime"
require "dependabot/utils"

# rubocop:disable Metrics/ModuleLength
module Dependabot
extend T::Sig

Expand All @@ -21,6 +22,7 @@ module ErrorAttributes
end

# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/CyclomaticComplexity
sig { params(error: StandardError).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
def self.fetcher_error_details(error)
case error
Expand Down Expand Up @@ -90,6 +92,11 @@ def self.fetcher_error_details(error)
"error-type": "private_source_authentication_failure",
"error-detail": { source: error.source }
}
when Dependabot::PrivateSourceBadResponse
{
"error-type": "private_source_bad_response",
"error-detail": { source: error.source }
}
when Octokit::Unauthorized
{ "error-type": "octokit_unauthorized" }
when Octokit::ServerError
Expand All @@ -113,6 +120,7 @@ def self.fetcher_error_details(error)
}
end
end
# rubocop:enable Metrics/CyclomaticComplexity

sig { params(error: StandardError).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
def self.parser_error_details(error)
Expand Down Expand Up @@ -167,6 +175,11 @@ def self.parser_error_details(error)
"error-type": "private_source_authentication_failure",
"error-detail": { source: error.source }
}
when Dependabot::PrivateSourceBadResponse
{
"error-type": "private_source_bad_response",
"error-detail": { source: error.source }
}
when Dependabot::GitDependenciesNotReachable
{
"error-type": "git_dependencies_not_reachable",
Expand Down Expand Up @@ -262,6 +275,11 @@ def self.updater_error_details(error)
"error-type": "private_source_authentication_failure",
"error-detail": { source: error.source }
}
when Dependabot::PrivateSourceBadResponse
{
"error-type": "private_source_bad_response",
"error-detail": { source: error.source }
}
when Dependabot::DependencyNotFound
{
"error-type": "dependency_not_found",
Expand Down Expand Up @@ -645,6 +663,20 @@ def initialize(source)
end
end

class PrivateSourceBadResponse < DependabotError
extend T::Sig

sig { returns(String) }
attr_reader :source

sig { params(source: T.nilable(String)).void }
def initialize(source)
@source = T.let(sanitize_source(T.must(source)), String)
msg = "Bad response error while accessing source: #{@source}"
super(msg)
end
end

class PrivateSourceTimedOut < DependabotError
extend T::Sig

Expand Down Expand Up @@ -846,3 +878,4 @@ def initialize(message = nil)
end
end
end
# rubocop:enable Metrics/ModuleLength
4 changes: 2 additions & 2 deletions docker/lib/dependabot/docker/update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def tags_from_registry
rescue *transient_docker_errors
attempt ||= 1
attempt += 1
raise if attempt > 3
raise PrivateSourceBadResponse, registry_hostname if attempt > 3

retry
end
Expand Down Expand Up @@ -232,7 +232,7 @@ def fetch_digest_of(tag)
attempt ||= 1
attempt += 1
return if attempt > 3 && e.is_a?(DockerRegistry2::NotFound)
raise if attempt > 3
raise PrivateSourceBadResponse, registry_hostname if attempt > 3

retry
rescue DockerRegistry2::RegistryAuthenticationException,
Expand Down
Loading