Skip to content

Commit

Permalink
Merge pull request #11412 from MikeMcQuaid/improve_github_packages_js…
Browse files Browse the repository at this point in the history
…on_manifest_error

software_spec: improve bad manifest error message.
  • Loading branch information
MikeMcQuaid committed May 19, 2021
2 parents 5d5571e + 60ab6b8 commit e916f93
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Library/Homebrew/software_spec.rb
Expand Up @@ -347,8 +347,20 @@ def stage
end

def fetch_tab
return if github_packages_manifest_resource.blank?

# a checksum is used later identifying the correct tab but we do not have the checksum for the manifest/tab
github_packages_manifest_resource&.fetch(verify_download_integrity: false)
github_packages_manifest_resource.fetch(verify_download_integrity: false)

begin
JSON.parse(github_packages_manifest_resource.cached_download.read)
rescue JSON::ParserError
raise DownloadError.new(
github_packages_manifest_resource,
RuntimeError.new("The downloaded GitHub Packages manifest was corrupted or modified (it is not valid JSON):"\
"\n#{github_packages_manifest_resource.cached_download}"),
)
end
rescue DownloadError
raise unless fallback_on_error

Expand All @@ -363,7 +375,8 @@ def tab_attributes
json = begin
JSON.parse(manifest_json)
rescue JSON::ParserError
raise ArgumentError, "Couldn't parse manifest JSON."
raise "The downloaded GitHub Packages manifest was corrupted or modified (it is not valid JSON): "\
"\n#{github_packages_manifest_resource.cached_download}"
end

manifests = json["manifests"]
Expand Down

0 comments on commit e916f93

Please sign in to comment.