-
Notifications
You must be signed in to change notification settings - Fork 22.2k
ActiveStorage Proxy fails on Puma with: undefined method `to_ary' #47561
Copy link
Copy link
Closed
Labels
Description
Steps to reproduce
Started with a barebones rails edge install with active_storage installed and a minimal test case:
app/models/picture_frame.rb
class PictureFrame < ApplicationRecord
has_one_attached :picture
end
db/migrate/20230302181354_create_picture_frames.rb
class CreatePictureFrames < ActiveRecord::Migration[7.0]
def change
create_table :picture_frames do |t|
t.timestamps
end
end
end
config/initializers/active_storage.rb
Rails.application.config.active_storage.resolve_model_to_route = :rails_storage_proxy
in rails console I manually set up a simple test case:
irb(main):001:0> p = PictureFrame.create
=> #<PictureFrame:0x000000010bb801a8 id: 2, created_at: Thu, 02 Mar 2023 19:37:21.674961000 UTC +00:00, updated_at: Thu, 02 Mar 2023 19:37:21.674961000 UTC +00:00>
irb(main):002:0> f = File.open('test.jpg')
=> #<File:test.jpg>
irb(main):003:0> p.picture.attach(io: f, filename: 'test.jpg', content_type: 'image/jpg')
...
irb(main):004:0> p.save
=> true
irb(main):005:0> app.rails_representation_path(p.picture)
=> "/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsiZGF0YSI6NCwicHVyIjoiYmxvYl9pZCJ9fQ==--f1cee12a7b22044d58c2e760c4e6bc5768191c94/test.jpg"
Same result when using variations too.
Expected behavior
As seen with rails commit e89b2e4
=> Booting Puma
=> Rails 7.1.0.alpha application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 6.1.1 (ruby 3.2.0-p0) ("The Way Up")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 6636
* Listening on http://127.0.0.1:3000
* Listening on http://[::1]:3000
Use Ctrl-C to stop
Started GET "/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6Ik1nPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--b8d84e5130fbf7942217e6aed28288da994320d2/test.jpg" for ::1 at 2023-03-02 11:27:05 -0800
ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by ActiveStorage::Blobs::ProxyController#show as JPEG
Parameters: {"signed_id"=>"eyJfcmFpbHMiOnsibWVzc2FnZSI6Ik1nPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--b8d84e5130fbf7942217e6aed28288da994320d2", "filename"=>"test"}
ActiveStorage::Blob Load (0.1ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ? [["id", 2], ["LIMIT", 1]]
Disk Storage (1.3ms) Downloaded file from key: avir98wqd0j07jcgpk5c19sb4mgt
Completed 200 OK in 70ms (ActiveRecord: 1.5ms | Allocations: 30861)
Actual behavior
As seen with all commits starting with 218ec10
=> Booting Puma
=> Rails 7.1.0.alpha application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 6.1.1 (ruby 3.2.0-p0) ("The Way Up")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 18300
* Listening on http://127.0.0.1:3000
* Listening on http://[::1]:3000
Use Ctrl-C to stop
Started GET "/rails/active_storage/blobs/proxy/eyJfcmFpbHMiOnsibWVzc2FnZSI6Ik1nPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--b8d84e5130fbf7942217e6aed28288da994320d2/test.jpg" for ::1 at 2023-03-02 11:28:44 -0800
ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by ActiveStorage::Blobs::ProxyController#show as JPEG
Parameters: {"signed_id"=>"eyJfcmFpbHMiOnsibWVzc2FnZSI6Ik1nPT0iLCJleHAiOm51bGwsInB1ciI6ImJsb2JfaWQifX0=--b8d84e5130fbf7942217e6aed28288da994320d2", "filename"=>"test"}
ActiveStorage::Blob Load (0.1ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ? [["id", 2], ["LIMIT", 1]]
Disk Storage (4.2ms) Downloaded file from key: avir98wqd0j07jcgpk5c19sb4mgt
2023-03-02 11:28:45 -0800 Read: #<NoMethodError: undefined method `to_ary' for #<Thread::SizedQueue:0x00000001049dd140>>
Completed 200 OK in 124ms (ActiveRecord: 1.6ms | Allocations: 31071)
System configuration
Rails version: Anything after 218ec10
Ruby version: 3.2.0
Rack version: Didn't seem to matter but the bulk of my tests were using 2.2.6.2
Puma version: 6.1.1 but saw similar results with earlier versions.
Likely caused by #47092
Reactions are currently unavailable