You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I receiving the following warning on rails console:
You are setting a key that conflicts with a built-in method OmniAuth::AuthHash::InfoHash#name defined at /home/vagrant/.rvm/gems/[email protected]/gems/omniauth-1.3.2/lib/omniauth/auth_hash.rb:34. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
Could some one help me?
Reacted by Lo Axhamre, Dewayne VanHoozer, Geremia Taglialatela, Vladimir, Gordon McNaughton, webmstk, taketnk, SHAKEEL, writetosalman, Alex Promakh and 1 more
This is due to a new feature we have in Hashie that logs when you're overwriting keys via method setters. There are several places in Omniauth where this might cause a problem.
On an application level, you can just disable the Hashie logger if you aren't using Mash anywhere else in your app. You can do that with the following:
Hashie.logger=Logger.new(nil)
If you're in a Rails app, do this in an initializer. Otherwise, do it during the bootstrap of your app.
I'm working on a patch to make this go away in Omniauth without user intervention.
Reacted by Suelen Carvalho, Yuxuan "Ethan" Chen, Danilo Barion Nogueira and Victória Olívia Araújo Vilas Boas
Reacted by Bryce McLean, Christian Malpeli, Kengo, Sergey Nartimov, Eebs Kobeissi, Daniel Westendorf, Raphael Kallensee, Matthew Broberg, Jake Dahn, Gordon McNaughton and 14 more
You are setting a key that conflicts with a built-in method OmniAuth::Strategy::Options#display defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
hashie/hashie#395 is the PR that will add functionality to let us override the warning behavior in OmniAuth. I'll get the PR for OmniAuth out as soon as I can.
If this code is modified to pass "first_name" => "Example", 'last_name' => "User" instead of "name" => "Example User", the warning disappears, and the name method can happily construct a name from the two strings.
😱 Seriously this is like playing Whack-a-Mole. Can you see if Hashie 3.5.3 fixes the issue? We have specific checks for logging in Hashie now and that should fix the problem.
The problem was the the fix in 3.5.2 didn't propagate to subclasses. 3.5.3 fixes it here.
@michaelherold
The exact warning is You are setting a key that conflicts with a built-in method OmniAuth::AuthHash::InfoHash#name defined at /data/bsa_website/shared/bundled_gems/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/auth_hash.rb:34. with Rails 4.2.8
Activity
bmclean commentedon Jan 31, 2017
@chandrasc The warning is coming from hashie (as of version 3.5.0) and was introduced here.
Discussion is happening here as well.
michaelherold commentedon Jan 31, 2017
Hi, Hashie maintainer here.
This is due to a new feature we have in Hashie that logs when you're overwriting keys via method setters. There are several places in Omniauth where this might cause a problem.
On an application level, you can just disable the Hashie logger if you aren't using Mash anywhere else in your app. You can do that with the following:
If you're in a Rails app, do this in an initializer. Otherwise, do it during the bootstrap of your app.
I'm working on a patch to make this go away in Omniauth without user intervention.
cmalpeli commentedon Feb 1, 2017
@michaelherold thanks. FYI adding that initializer did not stop the warning message.
masterkain commentedon Feb 2, 2017
I also have
You are setting a key that conflicts with a built-in method OmniAuth::Strategy::Options#display defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
michaelherold commentedon Feb 2, 2017
hashie/hashie#395 is the PR that will add functionality to let us override the warning behavior in OmniAuth. I'll get the PR for OmniAuth out as soon as I can.
tmilewski commentedon Feb 2, 2017
Perfect! Thank you @michaelherold!
evmorov commentedon Feb 2, 2017
You can add it to your Gemfile to suppress the warning
gem 'hashie', '~> 3.4.6'nathanl commentedon Feb 3, 2017
Useful or not, the conflict being warned about is the fact that
:nameis a key here:https://github.com/omniauth/omniauth/blob/v1.3.2/lib/omniauth.rb#L45
and also a method here:
https://github.com/omniauth/omniauth/blob/v1.3.2/lib/omniauth/auth_hash.rb#L34
If this code is modified to pass
"first_name" => "Example", 'last_name' => "User"instead of"name" => "Example User", the warning disappears, and the name method can happily construct a name from the two strings.But I don't know if that creates other problems.
tmilewski commentedon Feb 3, 2017
@nathanl Yeah, while possible, this would create one heck of a breaking change.
michaelherold commentedon Feb 3, 2017
Check out #874 for a proposed patch.
michaelherold commentedon Feb 10, 2017
I just released Hashie v3.5.2 which has the
disable_warningsfeature for the Mash logger. Hopefully, this helps!tmilewski commentedon Feb 11, 2017
@michaelherold @dblock It appears we may have regressed with
disable_warnings. If I remove the check (https://github.com/omniauth/omniauth/blob/master/lib/omniauth/key_store.rb#L11-L13) and force it throughlog_built_in_message... it works again.RSpec log: https://gist.github.com/tmilewski/05d2127e1ebd5b57b21d86aabab9408f
[-]New warning[/-][+]Hashie warnings[/+]michaelherold commentedon Feb 11, 2017
😱 Seriously this is like playing Whack-a-Mole. Can you see if Hashie 3.5.3 fixes the issue? We have specific checks for logging in Hashie now and that should fix the problem.
The problem was the the fix in 3.5.2 didn't propagate to subclasses. 3.5.3 fixes it here.
tmilewski commentedon Feb 11, 2017
@michaelherold That seems to do it! Thanks a lot for your help!
JulienItard commentedon Apr 6, 2017
@michaelherold
Hi i'm on Omniauth 1.3.1 and Hashie 3.5.5 but I still have this warning. Thanks
michaelherold commentedon Apr 6, 2017
@JulienItard are you getting the warning due to an Omniauth method or from something else that uses Hashie?
What Omniauth providers are you using?
JulienItard commentedon Apr 6, 2017
@michaelherold
The exact warning is
You are setting a key that conflicts with a built-in method OmniAuth::AuthHash::InfoHash#name defined at /data/bsa_website/shared/bundled_gems/ruby/2.3.0/gems/omniauth-1.3.1/lib/omniauth/auth_hash.rb:34.with Rails 4.2.8michaelherold commentedon Apr 6, 2017
You need to update to Omniauth 1.6.0+ to silence the error. 1.3.1 is too old.
Update omniauth gem to fix hashie warnings
Update omniauth from 1.3.1 to 1.8.1
(fix) Update Omniauth to supress deprecation
(fix) Update Omniauth to supress deprecation
(fix) Update Omniauth to supress deprecation
(fix) Update Omniauth to supress deprecation