logoalt Hacker News

psadauskasyesterday at 10:15 PM4 repliesview on HN

Fun story about that: In Ruby 2.x, the version GitHub originally launched with, every object implemented the method `id`, which returned the object id (in 3.x, it was renamed to `object_id`). Every object had this id, ActiveRecord models, strings, floats, integers, booleans, etc. Some objects had fixed object ids, like `true.object_id #=> 20`, `false.object_id #=> 0`, `123.object_id #=> 247 (2n+1)`. The `object_id` for `nil` is `4`.

Yehuda Katz was the first external user of GitHub after the cofounders, so his github user id is `4`.

The way Rails works, if you want to look up a user record, you do it by id:

    author = comment.author
    user = User.find(author.id)

Now, if there was some bug, and for some reason a comment had no author, `comment.author` would return `nil`, `nil.id` would return `4`, and the UI would show Yehuda as the author in the UI. People would ask, "Who is this Yehuda guy, and why is he commenting on my PRs?"

Replies

byroottoday at 1:00 AM

Similarly, when writing Facebook apps with Rails, when you'd hit that same bug you'd see Mark Zuckerbeg: https://www.facebook.com/profile.php?id=4

sikozuyesterday at 11:34 PM

I love this story, makes me wonder how many other fun bugs on GitHub have been lost to time.

tksbyesterday at 11:29 PM

These are the fun anecdotes that make perusing comments here so worth it. Thanks for sharing!

Dragonaiyesterday at 11:12 PM

This is too funny. Thanks for sharing this tidbit!