fog-openstack icon indicating copy to clipboard operation
fog-openstack copied to clipboard

undefined method `=~' for 3:Integer

Open GenieRobot opened this issue 1 year ago • 4 comments
trafficstars

I have a rather fresh install of activestorage-openstack, which seems to build upon fog-openstack.

I've tried to upload a test jpg file to my Infomaniak s3 comp object storage, but I get this error:

Loading development environment (Rails 7.1.3.2)
irb(main):001* blob = ActiveStorage::Blob.create_and_upload!(
irb(main):002*   io: File.open("./public/sleep.jpg", 'rb'),
irb(main):003*   filename: "sleep.jpg",
irb(main):004*   content_type: "image/jpg"
irb(main):005> )
  TRANSACTION (0.0ms)  begin transaction
  ActiveStorage::Blob Create (0.3ms)  INSERT INTO "active_storage_blobs" ("key", "filename", "content_type", "metadata", "service_name", "byte_size", "checksum", "created_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id"  [["key", "irdd44jxhg8zzh9ado2ogy61kzdj"], ["filename", "sleep.jpg"], ["content_type", "image/jpeg"], ["metadata", "{\"identified\":true}"], ["service_name", "infomaniak"], ["byte_size", 526621], ["checksum", "H3N/tmO1/TcKfCdnEyIOOQ=="], ["created_at", "2024-04-09 19:22:37.714505"]]
  TRANSACTION (6.6ms)  commit transaction
  OpenStack Storage (9.7ms) Uploaded file to key: irdd44jxhg8zzh9ado2ogy61kzdj (checksum: H3N/tmO1/TcKfCdnEyIOOQ==)
/home/un/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/fog-openstack-794aa8b36a06/lib/fog/openstack/auth/token.rb:17:in `build': undefined method `=~' for 3:Integer (NoMethodError)

It works when I use config.active_storage.service = :local but that's not the intention.

Copilot keeps telling me that I should fork your gem, rewrite it and try again.

I have already tried @chaadow's version but that has the same error

Please let me know if I can help

GenieRobot avatar Apr 09 '24 19:04 GenieRobot

It looks like it's receiving an integer for the api version, while expecting a string (and then erroring because it's trying to compare a regex to an integer instead of a string) here: https://github.com/fog/fog-openstack/blob/master/lib/fog/openstack/auth/token.rb#L17

It looks like it's expecting something like "v3", but receiving something like 3. Are you setting this value in the config for fog-openstack? It looked like it might be a config value, rather than something coming back from a call, but I haven't used this codebase in a very long time.

geemus avatar Apr 09 '24 20:04 geemus

No, I'm setting this value in the Rails credentials. But yes, what you say is exactly what Copilot said. Should be an easy fix. I'll try v3, too, but I don't think that it will work

GenieRobot avatar Apr 10 '24 10:04 GenieRobot

As expected, same error when using "v3".

GenieRobot avatar Apr 10 '24 10:04 GenieRobot

Using my patched version, the bug is gone but I still get an authentication error. At least one step ahead ^^'

GenieRobot avatar Apr 10 '24 11:04 GenieRobot