ActiveStorage Mirror Issue

Open
#562 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
rails, ruby
Domain
backend

Research direction

Reproduce the ActiveStorage Mirror check and upload with Ruby 3.0.0, Rails 7.0.4, and cloudinary 2.2.0. Start by comparing Cloudinary.config.cloud_name with the config_from_url call in config/initializers/cloudinary.rb and the Cloudinary and Mirror entries in config/storage.yml; done means the mirror upload completes without the “Must supply cloud_name” error.

Written by the indexing model from the issue text.

Description

I am trying to set up ActiveStorage mirror so that I can migrate from S3 into my Cloudinary. When I try to run the mirror check and upload, I'm getting an error, "RuntimeError (Must supply cloud_name)"

If I check Cloudinary.config, I get all the correct info:
#<OpenStruct cloud_name="airjoshb", api_key="my_key", api_secret="my_key", private_cdn=false, false=false, secure=true, enhance_image_tag=true, static_file_support=false>

But if I check Cloudinary.config.cloud_name, it returns false

If I try to run the mirror command locally, I get a bit more info in that it is confirming the file isn't in my mirror on Cloudinary
Cloudinary Storage (4.0ms) Checked if file exists at key: 3uxbbrz9kh4mw7iq2z2xzyuo1w2z (no) Mirror Storage (4.5ms) Mirrored file at key: 3uxbbrz9kh4mw7iq2z2xzyuo1w2z (checksum: DSAVwrDMF+tj9ncc9pCX2A==) /Users/joshua/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/cloudinary-2.2.0/lib/cloudinary/api.rb:1269:in call_api': Must supply cloud_name (RuntimeError)`

Any thoughts on why it finds the cloud_name but is returning false when I try to use it?

ruby 3.0.0p0
Rails 7.0.4
cloudinary (2.2.0)
activestorage (7.0.4)

I have tried all manner of configurations, using the cloudinary.yml in the config folder

development:
    cloud_name: airjoshb
    api_key: ENV.fetch('CLOUDINARY_KEY_ID')
    api_secret: ENV.fetch('CLOUDINARY_ACCESS_KEY')
    enhance_image_tag: true
    static_file_support: false

  production:
    cloud_name: airjoshb
    api_key: ENV.fetch('CLOUDINARY_KEY_ID')
    api_secret: ENV.fetch('CLOUDINARY_ACCESS_KEY')
    enhance_image_tag: true
    static_file_support: true

In an initializer, cloudinary.rb where the env includes the key:key@cloud_name format

require 'cloudinary'

Cloudinary.config_from_url("cloudinary://ENV.fetch('CLOUDINARY_URL')")
Cloudinary.config do |config|
  config.secure = true
  config.enhance_image_tag = true
  config.static_file_support= false
end

And, my storage.yml is super simple, as the gem seems to prefer using the initializer

cloudinary:
  service: Cloudinary
  folder: switch-bakery

# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
amazon:
  service: S3
  access_key_id:     <%= ENV.fetch('AWS_ACCESS_KEY_ID') %>
  secret_access_key: <%= ENV.fetch('AWS_SECRET_ACCESS_KEY') %>
  region:            'us-west-1'
  bucket: <%= ENV.fetch('S3_BUCKET_NAME') %>

production:
  service: Mirror
  primary: amazon
  mirrors:
    - cloudinary
Dominant language
Ruby
Stars
420
Forks
282
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudinary/cloudinary_gem

All issues in cloudinary/cloudinary_gem

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.