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

Regression in 0.11.4? #133

Open
jherdman opened this issue Jul 19, 2022 · 1 comment
Open

Regression in 0.11.4? #133

jherdman opened this issue Jul 19, 2022 · 1 comment

Comments

@jherdman
Copy link

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:/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:/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.

@hogelog
Copy link

hogelog commented May 21, 2023

Rack::Session::SessionId was introduced at #146 and fixed this problem.

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

No branches or pull requests

2 participants