Skip to content

Hashie warnings #872

Closed
Closed

Description

@chandrasc

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?

Activity

  1. bmclean commented on Jan 31, 2017

    @bmclean

    @chandrasc The warning is coming from hashie (as of version 3.5.0) and was introduced here.
    Discussion is happening here as well.

  2. michaelherold commented on Jan 31, 2017

    @michaelherold
    Contributor

    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:

    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.

  3. cmalpeli commented on Feb 1, 2017

    @cmalpeli

    @michaelherold thanks. FYI adding that initializer did not stop the warning message.

  4. masterkain commented on Feb 2, 2017

    @masterkain

    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.

  5. michaelherold commented on Feb 2, 2017

    @michaelherold
    Contributor

    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.

  6. tmilewski commented on Feb 2, 2017

    @tmilewski
    Member

    Perfect! Thank you @michaelherold!

  7. evmorov commented on Feb 2, 2017

    @evmorov

    You can add it to your Gemfile to suppress the warning gem 'hashie', '~> 3.4.6'

  8. nathanl commented on Feb 3, 2017

    @nathanl

    Useful or not, the conflict being warned about is the fact that :name is 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.

  9. tmilewski commented on Feb 3, 2017

    @tmilewski
    Member

    @nathanl Yeah, while possible, this would create one heck of a breaking change.

  10. michaelherold commented on Feb 3, 2017

    @michaelherold
    Contributor

    Check out #874 for a proposed patch.

  11. michaelherold commented on Feb 10, 2017

    @michaelherold
    Contributor

    I just released Hashie v3.5.2 which has the disable_warnings feature for the Mash logger. Hopefully, this helps!

  12. tmilewski commented on Feb 11, 2017

    @tmilewski
    Member
  13. changed the title [-]New warning[/-] [+]Hashie warnings[/+] on Feb 11, 2017
  14. michaelherold commented on Feb 11, 2017

    @michaelherold
    Contributor

    😱 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.

  15. tmilewski commented on Feb 11, 2017

    @tmilewski
    Member

    @michaelherold That seems to do it! Thanks a lot for your help!

  16. JulienItard commented on Apr 6, 2017

    @JulienItard

    @michaelherold
    Hi i'm on Omniauth 1.3.1 and Hashie 3.5.5 but I still have this warning. Thanks

  17. michaelherold commented on Apr 6, 2017

    @michaelherold
    Contributor

    @JulienItard are you getting the warning due to an Omniauth method or from something else that uses Hashie?

    What Omniauth providers are you using?

  18. JulienItard commented on Apr 6, 2017

    @JulienItard

    @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

  19. michaelherold commented on Apr 6, 2017

    @michaelherold
    Contributor

    You need to update to Omniauth 1.6.0+ to silence the error. 1.3.1 is too old.

  20. added theissue type on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions