bump: retry, then skip packages on transient GitHub API errors

A single failed GitHub API call (e.g. a transient TLS failure returning
a self-signed certificate on the runner) currently aborts the whole
`brew bump` run, leaving all remaining packages unprocessed. Because
the package list is processed in a fixed alphabetical order, packages
later in the list are starved whenever errors recur.

Instead, retry the same package once after a short sleep, then skip it
and continue. Abort after 5 consecutive package failures so a sustained
GitHub outage still stops the run quickly, and re-raise rate limit and
authentication errors immediately since retrying other packages cannot
succeed in those cases.
This commit is contained in:
moscowmule2240
2026-08-12 21:56:31 +09:00
parent 0d7b47e8d8
commit 0dec630427
+30 -6
View File
@@ -25,6 +25,8 @@ module Homebrew
timeout: 60,
retries: 0,
}.freeze, T::Hash[Symbol, T.untyped])
MAX_CONSECUTIVE_GITHUB_API_ERRORS = 5
GITHUB_API_ERROR_RETRY_SLEEP = 5
PYPI_UNSTABLE_VERSION_REGEX = /^(?:\d+!)?\d+(?:\.\d+)*(?:a|b|rc)\d+|\.dev\d+$/i
LIVECHECK_MESSAGE_REGEX = /^(?:error:|skipped|unable to get(?: throttled)? versions)/i
@@ -849,6 +851,7 @@ module Homebrew
.flatten
end
consecutive_github_api_errors = 0
formulae_and_casks.each_with_index do |formula_or_cask, i|
puts if i.positive?
next if skip_ineligible_formulae!(formula_or_cask)
@@ -863,12 +866,33 @@ module Homebrew
package_data = Repology.single_package_query(name, repository:) unless skip_repology?(formula_or_cask)
retrieve_and_display_info_and_open_pr(
formula_or_cask,
name,
package_data&.values&.first || [],
ambiguous_cask: ambiguous_casks.include?(formula_or_cask),
)
retried = T.let(false, T::Boolean)
begin
retrieve_and_display_info_and_open_pr(
formula_or_cask,
name,
package_data&.values&.first || [],
ambiguous_cask: ambiguous_casks.include?(formula_or_cask),
)
consecutive_github_api_errors = 0
rescue GitHub::API::RateLimitExceededError, GitHub::API::AuthenticationFailedError
# Retrying these for the remaining packages cannot succeed, so stop now.
raise
rescue GitHub::API::Error => e
unless retried
retried = true
onoe "#{name}: retrying after a GitHub API error: #{e}"
sleep GITHUB_API_ERROR_RETRY_SLEEP
retry
end
consecutive_github_api_errors += 1
if consecutive_github_api_errors >= MAX_CONSECUTIVE_GITHUB_API_ERRORS
odie "Aborting after #{consecutive_github_api_errors} consecutive GitHub API errors: #{e}"
end
onoe "#{name}: skipped after a GitHub API error: #{e}"
end
end
end