Hi folks,

I just found a workaround for that issue. Apparently, the issue is a
missing type check/type confusion in "etag" (or in the invocation of
this lib). With the patch attached to this mail, artifacts can be
uploaded again.

To debug the issue, I added a begin/resuce block around the failing call
to @app.call in lib/gitlab/middleware/read_only/controller.rb:51 and
dumped the entire stack trace:

          begin
            @app.call(@env)
          rescue NoMethodError => e
            Gitlab::AppLogger.error("Here we are")
            Gitlab::AppLogger.error(e.message)
            e.backtrace.each { |line| Gitlab::AppLogger.error(line) }
          end

The result was dumped into the "application.log" and clearly showed the
origin of the exception:

2020-12-19T15:54:30.166Z: Here we are
2020-12-19T15:54:30.168Z: undefined method `empty?' for 201:Integer
2020-12-19T15:54:30.169Z: /usr/lib/ruby/vendor_ruby/rack/etag.rb:70:in
`block in digest_body'
2020-12-19T15:54:30.169Z:
/usr/lib/ruby/vendor_ruby/rack/body_proxy.rb:34:in `block in each'
2020-12-19T15:54:30.169Z:
/usr/lib/ruby/vendor_ruby/rack/body_proxy.rb:34:in `each'
2020-12-19T15:54:30.170Z:
/usr/lib/ruby/vendor_ruby/rack/body_proxy.rb:34:in `each'
2020-12-19T15:54:30.170Z: /usr/lib/ruby/vendor_ruby/rack/etag.rb:68:in
`digest_body'
2020-12-19T15:54:30.170Z: /usr/lib/ruby/vendor_ruby/rack/etag.rb:31:in
`call'
2020-12-19T15:54:30.170Z:
/usr/lib/ruby/vendor_ruby/rack/conditional_get.rb:40:in `call'
2020-12-19T15:54:30.170Z: /usr/lib/ruby/vendor_ruby/rack/head.rb:14:in
`call'
2020-12-19T15:54:30.171Z:
/usr/share/rubygems-integration/all/gems/actionpack-6.0.3.1/lib/action_dispatch/http/content_security_policy.rb:18:in
`call'
2020-12-19T15:54:30.171Z:
/usr/share/gitlab/lib/gitlab/middleware/read_only/controller.rb:52:in `call'

So, right now, I do have a workaround, although I don't where the
problem is exactly (i.e., in gitlab or in etag) nor how it should be
fixed. I hope this helps debugging the issue further!

Best,
Maximilian

--- /usr/lib/ruby/vendor_ruby/rack/etag.rb.old  2020-12-19 18:54:53.266122418 +0100
+++ /usr/lib/ruby/vendor_ruby/rack/etag.rb.new  2020-12-19 18:54:04.169502266 +0100
@@ -67,7 +67,7 @@

         body.each do |part|
           parts << part
-          (digest ||= Digest::SHA256.new) << part unless part.empty?
+          (digest ||= Digest::SHA256.new) << part if part.is_a?(String) && !part.empty?
         end

         [digest && digest.hexdigest.byteslice(0, 32), parts]

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to