Skip to content

InfoHash.slice.to_hash does not return expected keys #892

Closed

Description

@jasonkarns

Please complete all sections.

Configuration

  • Provider Gem: n/a
  • Ruby Version: 2.3.3
  • Framework: Rails 5.0.1
  • Platform: OS X

Expected Behavior

Slicing an InfoHash and then invoking to_hash should result in a Hash with only the keys specified in the slice call.

Actual Behavior

Instead, the resulting hash contains the sliced keys and name

Steps to Reproduce

irb> h = OmniAuth::AuthHash::InfoHash.new({email: 'foo', name: 'bar'})
=> #<OmniAuth::AuthHash::InfoHash email="foo" name="bar">
irb> h.slice(:email)
=> #<OmniAuth::AuthHash::InfoHash email="foo">
irb> h.slice(:email).to_hash
=> {"email"=>"foo", "name"=>"foo"}

The offending code is

def to_hash
hash = super
hash['name'] ||= name
hash
end
(which is a violation of Liskov substitution principle)

Activity

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

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions