In https://bugzilla.mozilla.org/show_bug.cgi?id=1365328 we discovered that the tokenserver returns a "500 server error" when requesting a URL with invalid utf8 in the path component, such as "/%FF". There's no harm in erroring out, but let's do it cleanly so that the server logs aren't filled with spurious 500 errors.
This adds an exception view to convert the exception into a 404, which appears to be the recommended approach for pyramid. It also slightly adjusts the metrics-gathering code, which assumes that the path can be converted to a string, and which was previously running before pyramid got a chance to route-match the path and detect it as invalid.
In https://bugzilla.mozilla.org/show_bug.cgi?id=1365328 we discovered that the tokenserver returns a "500 server error" when requesting a URL with invalid utf8 in the path component, such as "/%FF". There's no harm in erroring out, but let's do it cleanly so that the server logs aren't filled with spurious 500 errors.
This adds an exception view to convert the exception into a 404, which appears to be the recommended approach for pyramid. It also slightly adjusts the metrics-gathering code, which assumes that the path can be converted to a string, and which was previously running before pyramid got a chance to route-match the path and detect it as invalid.
@Natim r?