ruby-changes:62477
From: David <ko1@a...>
Date: Fri, 31 Jul 2020 21:08:52 +0900 (JST)
Subject: [ruby-changes:62477] 3921ab8291 (master): [rubygems/rubygems] Let more exceptions flow
https://git.ruby-lang.org/ruby.git/commit/?id=3921ab8291 From 3921ab8291925f2d177535d38d2aaaa020f5d546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Sun, 12 Jul 2020 22:18:01 +0200 Subject: [rubygems/rubygems] Let more exceptions flow If any error happens while verifying a package entry, it doesn't mean that the package is corrupt. It could be a bug in rubygems, for example. This in fact happened in CI and the current error doesn't make it easy to troubleshoot the root cause, since it doesn't provide a backtrace. See https://github.com/rubygems/rubygems/pull/3807/checks?check_run_id=862526615. So I propose to let the exception happens. There was something useful about the previous message, which is the file entry where the error happened, so I'm keeping that information in a warning message. https://github.com/rubygems/rubygems/commit/ece87d858f diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb index 53ae696..9b53cd4 100644 --- a/lib/rubygems/package.rb +++ b/lib/rubygems/package.rb @@ -669,10 +669,9 @@ EOM https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package.rb#L669 when 'data.tar.gz' then verify_gz entry end - rescue => e - message = "package is corrupt, exception while verifying: " + - "#{e.message} (#{e.class})" - raise Gem::Package::FormatError.new message, @gem + rescue + warn "Exception while verifying #{@gem.path}" + raise end ## diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb index 1a9ca15..5e9c3b7 100644 --- a/test/rubygems/test_gem_package.rb +++ b/test/rubygems/test_gem_package.rb @@ -1065,11 +1065,22 @@ class TestGemPackage < Gem::Package::TarTestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package.rb#L1065 package = Gem::Package.new @gem - e = assert_raises Gem::Package::FormatError do - package.verify_entry entry + _, err = use_ui @ui do + e = nil + + out_err = capture_io do + e = assert_raises ArgumentError do + package.verify_entry entry + end + end + + assert_equal "whatever", e.message + assert_equal "full_name", e.backtrace_locations.first.label + + out_err end - assert_equal "package is corrupt, exception while verifying: whatever (ArgumentError) in #{@gem}", e.message + assert_equal "Exception while verifying #{@gem}\n", err valid_metadata = ["metadata", "metadata.gz"] valid_metadata.each do |vm| -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/