Sennheiser RS 140 Wireless Balanced HeadphonesThey look like ordinary headphones. I even have them on my wishlist and I like them - and yet they’ve haunted me for months.

It all started 5 months ago, when an early beta tester reported that these headphones mysteriously appeared on her list. I looked into it and they didn’t seem out of the ordinary, aside from the fact that they didn’t have a rating (and back in those days, we didn’t have the little green check marks, so everything had to have a rating). Months went by and there were no similar issues. Eventually, the headphones started popping up on other people’s lists. No other item in the entire catalog of wishes had ever done this. Just those headphones, and just certain people. If they deleted them, eventually they’d come back. The headphones were unstoppable.

Pouring through the logs, the best clue I had was that this was happening at night, probably during our scheduled Amazon sync. The users who were affected also happened to be users who had linked Amazon wishlists, although not every user with a linked Amazon wishlist got the headphones. The headphones aren’t even interesting. There are no weird characters in the name, and they didn’t even have a particularly special ID (it’s 4). Today, at long last, the mystery was solved.

There were two things at play here. First off, I had a bug where, when Amazon sends an invalid item to us (as it occasionally does) I wasn’t doing proper checking, and was instead creating a wish on the person’s list to correspond to that (null) item. One would hope that would cause some sort of obvious error, but it did not. So, whenever Amazon sent us a poorly-formatted item (no name, or no ASIN) we’d still import that as a wish onto people’s wishlists.

So, why would these invalid wishes become headphones?

(WARNING: semi-technical stuff ahead)

This is the answer:

irb(main):001:0> nil.id
(irb):1: warning: Object#id will be deprecated; use Object#object_id
=> 4

In Ruby, everything is an object - even null (which is called ‘nil’). Every object has an id. As you can see above, they’re deprecating the use of ‘id’ and switching to the more descriptive ‘object_id’. In Rails, ActiveRecord objects currently override the ‘id’ method. What was happening is that I was creating a wish on someone’s wishlist with the id of a nil object. It logged a warning about the deprecated method, and returned the id of nil. The object id of nil is 4. The id of the headphones is 4. Mystery solved, bug fixed.

(end technical talk)

In short, if these headphones have appeared on your wishlist, you need only delete them one last time. They won’t be back. I can finally sleep easy now. Sorry if these headphones appeared on your list (however, they really are good headphones).

One Response to “The case of the mysterious headphones”

  1. Matt Winn Says:

    Tom:

    That’s a story for the books; kudos on the troubleshooting. There’s something postmodern about representing the nil set.

    Best,
    Matt

Leave a Reply