software_spec: improve bad manifest error message.

Let's complain immediately after fetching if there's something wrong
and improve the error message to make it clearer what's going on.

Inspired by #76336.
This commit is contained in:
Mike McQuaid 2021-05-19 13:15:33 +01:00
parent ec2271cea7
commit 60ab6b86e9
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70

View File

@ -347,8 +347,20 @@ class Bottle
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
@ -363,7 +375,8 @@ class Bottle
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"]