Skip to content

Regression in 0.11.4? #133

@jherdman

Description

@jherdman

In 0.11.4 the following change was introduced:

3ee0426

I'm seeing this exception raised in Rack v2.2.3.1:

NoMethodError:
       undefined method `cookie_value' for "e1af07cec3cbb9aade2800550652e7bc":String

This can be traced to this line:

https://github.com/rack/rack/blob/925a4a6599ab26b4f3455b525393fe155d443655/lib/rack/session/abstract/id.rb#L482-L484

It seems that the data returned by set_session is a simple string, but a different data structure is expected:

def set_session(env, sid, session_data, options = nil)
expiry = get_expiry(env, options)
if expiry
redis.setex(prefixed(sid), expiry, encode(session_data))
else
redis.set(prefixed(sid), encode(session_data))
end
sid
rescue Errno::ECONNREFUSED, Redis::CannotConnectError => e
on_redis_down.call(e, env, sid) if on_redis_down
false
end
alias write_session set_session

If you dig into ActionDispatch::Session::CookieStore we can see that it's write_session implementation return a Rack::Session::SessionId instance (albeit decorated):

https://github.com/rails/rails/blob/04972d9b9ef60796dc8f0917817b5392d61fcf09/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb#L104-L107

If one returns an appropriately crafted instance this package works again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions