ObjectID.createFromHexString not recognizing inputted hexstring

I am going through Ciaran Jessup's walkthrough of creating a basic blog as an introduction to node. When i try to view an article, I get the following error:

500 Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters
at Function.createFromHexString (/Users/me/Dropbox/projects/node/howtonode_blog/node_modules/mongodb/node_modules/bson/lib/bson/objectid.js:212:11)
at /Users/me/Dropbox/projects/node/howtonode_blog/articleprovider-mongodb.js:38:64
at /Users/me/Dropbox/projects/node/howtonode_blog/articleprovider-mongodb.js:16:10
at Db.collection (/Users/me/Dropbox/projects/node/howtonode_blog/node_modules/mongodb/lib/mongodb/db.js:484:44)
at ArticleProvider.getCollection (/Users/me/Dropbox/projects/node/howtonode_blog/articleprovider-mongodb.js:14:11)
at ArticleProvider.findById (/Users/me/Dropbox/projects/node/howtonode_blog/articleprovider-mongodb.js:34:10)
at app.post.articleProvider.addCommentToArticle.person (/Users/me/Dropbox/projects/node/howtonode_blog/app.js:51:19)
at callbacks (/Users/me/Dropbox/projects/node/howtonode_blog/node_modules/express/lib/router/index.js:161:37)
at param (/Users/matty/Dropbox/projects/node/howtonode_blog/node_modules/express/lib/router/index.js:135:11)
at param (/Users/matty/Dropbox/projects/node/howtonode_blog/node_modules/express/lib/router/index.js:132:11)

Here are the relevant pieces of code:

From app.js:

app.get('/blog/:id', function(req, res) {
  articleProvider.findById(req.param.id, function(error, article) {
    res.render('blog_show.jade',{title: article.title, article: article})
  })
})

From articleprovider-mongodb.js:

ArticleProvider.prototype.findById = function(id, callback) {
    this.getCollection(function(error, article_collection) {
      if(error) callback(error);
      else {
        article_collection.findOne(
         // THIS IS THE LINE IN QUESTION BELOW
          {_id: article_collection.db.bson_serializer.ObjectID.createFromHexString(id)}, 
          function(error, result) {
            if(error) callback(error);
            else callback(null, result);
          }
        );
      }
    });
};

I have tried to convert the id object to a string along with trying to pass it as an object directly. However, my javascript is pretty bad, and I am having no luck. I have tried passing String(id) and id + "" rather than id along with:

{_id: id}

and

{_id: article_collection.db.bson_serializer.ObjectID(id)}

I would really appreciate someone pointing out what I'm doing wrong.

Thanks for reading!

EDIT: console.log("req.param.id is " + req.param.id) outputs "req.param.id is undefined" The url, http://localhost:3000/blog/516afb1064036bb345000001, is correct, though, as I passed 516afb1064036bb345000001 directly to the ArticleProvider.findById call and it worked.

EDIT 2: It worked when I changed req.param.id to req.params.id. However, in my app.post function I used the singular param as follows and still works:

articleProvider.save({
    title: req.param('title'),
    body: req.param('body')
  }  ...

Why is it that the singular param works here? Does params refer specifically to parameters passed in the URI?

without actually showing what id is being passed, i would recommend you validate the route. add this:

app.get('/blog/:id([0-9a-f]{24})'

this will make sure the id passed is always valid.

it's also better just to grab ObjectID from the mongodb or bson libraries instead of reaching so many levels.

var ObjectID = require('mongodb').ObjectID

// later
var id = ObjectID.createFromHexString(req.params.id)

if these don't work, please show us the actual string being passed via console.log(req.params.id)

also, that last callback inside your findOne() query is completely unnecessary. in fact, you can just do collection.findOne(id, callback)