Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figaro: key not found: "UPLOADCARE_PUBLIC_KEY" #117

Closed
georgesve opened this issue Feb 22, 2023 · 2 comments
Closed

Figaro: key not found: "UPLOADCARE_PUBLIC_KEY" #117

georgesve opened this issue Feb 22, 2023 · 2 comments
Labels

Comments

@georgesve
Copy link

key not found: "UPLOADCARE_PUBLIC_KEY"

When using Figaro for storing keys in application.yml I get the following error message when running rails c or rails s:

/Users/xx/.rvm/gems/ruby-3.1.2/gems/uploadcare-ruby-4.2.0/lib/uploadcare.rb:48:in `fetch': key not found: "UPLOADCARE_PUBLIC_KEY" (KeyError)

from /Users/xx/.rvm/gems/ruby-3.1.2/gems/uploadcare-ruby-4.2.0/lib/uploadcare.rb:48:in `<module:Uploadcare>'

It works when I manually import the keys like so

export UPLOADCARE_PUBLIC_KEY=your_public_key
export UPLOADCARE_SECRET_KEY=your_private_key

But I get the following warning + I have to manually export keys on every new terminal I work on:

WARNING: Skipping key "UPLOADCARE_PUBLIC_KEY". Already set in ENV.
WARNING: Skipping key "UPLOADCARE_SECRET_KEY". Already set in ENV.

uploadcare.rb

Uploadcare::Rails.configure do |config|
  config.public_key = ENV.fetch('UPLOADCARE_PUBLIC_KEY', 'demopublickey')
  config.secret_key = ENV.fetch('UPLOADCARE_SECRET_KEY', 'demosecretkey')
 ...
end

Expected behavior

I should be able to set the variables in application.yml

Code / screenshots

Environment

gemfile.lock

uploadcare-rails (3.2.0)
      rails (>= 4)
      uploadcare-ruby (>= 4.2)
uploadcare-ruby (4.2.0)
      api_struct (~> 1.0.1)
      mimemagic
      parallel
      retries
dry-configurable (= 0.13.0)

ruby-3.1.2

rails, 6.1.6

@georgesve georgesve added the bug label Feb 22, 2023
@kraft001
Copy link
Collaborator

@georgesve Yes, indeed, ENV keys were fetched in the gem before Figaro initialized them.
Fixed in the new version 4.3.1, you can find a sample application with Figjam here. I used Figjam as a new version of Figaro, as it's described in this comment
Please, try it and let me know if you still experience the issue.

@georgesve
Copy link
Author

@kraft001 problem solved with your fix ! thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants