Fix TypeError in RandomCommentMiddleware