Fix to prevent error when $id is not a MongoId
add a validity check on Uid