[x] I have added a description of my changes and why I'd like them included in the section below
Description of Changes
If someone called a route that didn't exist we would return 500 because a tower_http::request_id::RequestId couldn't be found in request extensions. That happened because the error handling middleware (which is invoked on timeouts and other middleware errors) tried to extract it. However the extension would be set inside a route_layer which is only called if there is a matching route. So if someone called route that didn't exist the request id extension would be missing and cause the error.
The solution is to reorder the middleware such that request ids are always set.
I have tested this with our internal services and verified that it does actually work.
Checklist
Description of Changes
If someone called a route that didn't exist we would return 500 because a
tower_http::request_id::RequestId
couldn't be found in request extensions. That happened because the error handling middleware (which is invoked on timeouts and other middleware errors) tried to extract it. However the extension would be set inside aroute_layer
which is only called if there is a matching route. So if someone called route that didn't exist the request id extension would be missing and cause the error.The solution is to reorder the middleware such that request ids are always set.
I have tested this with our internal services and verified that it does actually work.
Related Issues
List related issues here