rails: A JSON::ParserError occurred in controller#method

I just upgraded from Rails 4.0.2 to 4.1.1 and I’m receiving the following error (via the exception_notification gem).

A JSON::ParserError occurred in articles#show:

  795: unexpected token at '{I"session_id:ETI"%4caed1ded93646981589c00f1c56b926;'
  app/controllers/articles_controller.rb:17:in `show'

If I try and manually recreate the error I am unable to do it. The page renders correctly. I am however getting a steady stream of errors emailed to me since upgrading to Rails 4.1.1. My particular application is not directly using JSON or parsing it anywhere (although I can’t vouch for the gems I’m using).

I’m seeing this error on multiple pages. It’s occurring in actions that heavily touch the database, on actions that render simple content and an action that renders an atom feed.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 16 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@abatko I can’t speak on behalf of the Rails core team, but I’ll try my best to answer your questions:

  1. Once you know that all your users have visited your site at some point since you switched to hybrid. You’ll never really know for sure, but 6 months or a year should leave you with a pretty safe margin.

  2. There are 2 risks to leaving hybrid, but IMO neither is something to worry about: a. it may be deprecated at some point, but if so, I would expect that you’d see a deprecation warning at some point b. Every time the cookie is deserialized, Rails need to first check what type of cookie it is–json or marshal–and then deserialize it the right way. If there are no users with a marshal cookie, then this check is a waste of time, so switching to json will save a few cycles. However, the performance improvement will probably be insignificant.

  3. The same error that happened to @roberts1000 (see first comment on this issue) will happen to them

  1. At what point, if ever, should :hybrid be changed to :json in our apps?
  2. Is there any negative implication to leaving :hybrid forever?
  3. If/when we switch from :hybrid to :json, what will happen to users whose cookies were not converted?