Merge pull request #11412 from MikeMcQuaid/improve_github_packages_json_manifest_error

software_spec: improve bad manifest error message.
This commit is contained in:
Mike McQuaid 2021-05-19 14:37:10 +01:00 committed by GitHub
commit e916f9316e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -347,8 +347,20 @@ class Bottle
end end
def fetch_tab 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 # 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 rescue DownloadError
raise unless fallback_on_error raise unless fallback_on_error
@ -363,7 +375,8 @@ class Bottle
json = begin json = begin
JSON.parse(manifest_json) JSON.parse(manifest_json)
rescue JSON::ParserError 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 end
manifests = json["manifests"] manifests = json["manifests"]