Fix undefined method source error thrown by some middlewares.