shrinerb / shrine

File Attachment toolkit for Ruby applications

Home Page:https://shrinerb.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shrine 3.5.0 does not support Rack 3 (undefined method `map' for #Rack::Files::Iterator)

vrodic opened this issue · comments

When using a Rails 7 application with Rack 3 and Shrine 3.5.0 we are getting a

NoMethodError

undefined method `map' for #<Rack::Files::Iterator:0x0000786dd78a7560 @path="/tmp/image_processing20240221-90664-78pq2t.jpg", @ranges=[0..1343], @options={:mime_type=>"image/jpeg", :size=>1344}>


shrine (3.5.0) lib/shrine/plugins/derivation_endpoint.rb:368:in `call`

This is the offending line:

headers["Content-Length"] ||= body.map(&:bytesize).inject(0, :+).to_s

I see there are already PRs to fix this:

#661
#660

#660 and #661 fixes this.

The former fixes the underlying header capitalization change issue introduced on Rack > 2, while the latter fixes Shrine's fallback that should've guarded against this.

Should be fixed by #682.