Skip to content
This repository

cannot parse Cookie header: undefined method `size' for nil:NilClass #386

Closed
sporkd opened this Issue May 10, 2012 · 6 comments

7 participants

Peter Gumeson James Tucker sgrunberger Steve Purcell Samer Masry Rafael Mendonça França
Peter Gumeson
sporkd commented May 10, 2012

When working on multiple rails projects I kept getting the following error:

NoMethodError
cannot parse Cookie header: undefined method `size' for nil:NilClass

I could temporarily fix by deleting my browser cookies. However, not until I pointed to master branch of Rack was I able to make the problem go away for good.

I posted this solution on StackOverflow, and it seems it's fixing it for others as well.
http://stackoverflow.com/questions/9054604/rails-3-2-1-cannot-parse-cookie-header-undefined-method-size-for-nilnilcla

vitaliy commented May 15, 2012

We hit same issue when upgrading to rails 3.2.3. The issue is caused by empty params in the cookie query string. It's already fixed in the master by this commit: cb05a10

We could not use master branch as it caused other error in our test suite. So ended up forking, branching of 1.4.1 and cherry-picking the commit above.

sgrunberger

Actually, an earlier commit contains the actual fix, I believe:

2dfe940

On our large site, we've seen many of these errors caused by malformed Google Analytics cookies. I'm surprised there hasn't been more of a groundswell to get a new rack release out because of this problem.

Steve Purcell

Yep, I'm seeing this too, since upgrading from Rails 3.2.3 to 3.2.5, with the Rack version unchanged at 1.4.1.

Steve Purcell

For the impatient, here's a monkey-patch file: https://gist.github.com/2877275

Samer Masry
smasry commented June 09, 2012

I'm noticing it too. Here's a quick way to reproduce ...
lib/rack/request.rb:263 sets the separator to ";,"

If the cookie value has commas in it

Rack::Utils.parse_query("utmcct=/some/value/0,,,00.html; ", ';,')
...
NoMethodError: undefined method `size' for nil:NilClass

Two approaches you can take are to either drop the pair as in @purcell approach above or try to clean it.

Rafael Mendonça França

This issue is already fixed by #378.

James Tucker raggi closed this November 02, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.