-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
I'm upgrading an application currently using Rack 1.6.11 to the latest Rack 2.2.2. I'm running in to an issue with Rack::Session::Cookie configured with coder: Rack::Session::Cookie::Base64::JSON.new:
NoMethodError:
undefined method `public_id' for #<String:0x00007f868b8594e0>
Did you mean? public_send
# ./.bundle/gems/rack-2.2.2/lib/rack/session/abstract/id.rb:458:in `[]'
I've reduced this down to:
require "rack"
# Rack::Session::Cookie needs this but doesn't require it?
require "delegate"
# our app
app = Proc.new do |env|
# write something to the session to create the cookie on first call
env["rack.session"]["foo"] = "bar"
# read session ID to trigger bug on second call
env["rack.session"]["session_id"]
[200, {}, ["ok"]]
end
# wrap app in cookie session middleware, with json coder
wrapped = Rack::Session::Cookie.new(app,
secret: "foo",
coder: Rack::Session::Cookie::Base64::JSON.new)
# first call to get a cookie
env = {}
status, headers, body = wrapped.call(env)
cookie = headers["Set-Cookie"].split(";").first
# trigger the bug
env = {"HTTP_COOKIE" => cookie}
wrapped.call(env)This worked fine with 1.6.11 (and presumably before, although I haven't tested), and with 2.0.1 through 2.0.7.
1.6.12 and 1.6.13 fail because the json library used (OkJson) refuses to encode Rack::Session::SessionId.
2.0.8 fails with RuntimeError and no message.
2.0.9 is the start of the NoMethodError: undefined method 'public_id' error.
Metadata
Metadata
Assignees
Labels
No labels