From bd75ca674e5cf3e819e90ee46d0d792302d16d24 Mon Sep 17 00:00:00 2001 From: Martin Bornhold Date: Thu, 6 Oct 2016 15:50:37 +0200 Subject: [PATCH] wsgi-stack: Move the vcs middleware out of the error handling. Currently we are bypassing the error handling in case of responses from the vcs middleware with a custom response header. By moving it out of the error handling we don't need the custom header anymore. --- rhodecode/config/middleware.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rhodecode/config/middleware.py b/rhodecode/config/middleware.py index d8abeb52..1a7bc26b 100644 --- a/rhodecode/config/middleware.py +++ b/rhodecode/config/middleware.py @@ -186,12 +186,6 @@ def make_not_found_view(config): pylons_app, appenlight_client = wrap_in_appenlight_if_enabled( pylons_app, settings) - # The VCSMiddleware shall operate like a fallback if pyramid doesn't find - # a view to handle the request. Therefore we wrap it around the pylons app. - if vcs_server_enabled: - pylons_app = VCSMiddleware( - pylons_app, settings, appenlight_client, registry=config.registry) - # The pylons app is executed inside of the pyramid 404 exception handler. # Exceptions which are raised inside of it are not handled by pyramid # again. Therefore we add a middleware that invokes the error handler in @@ -202,6 +196,15 @@ def make_not_found_view(config): pylons_app = PylonsErrorHandlingMiddleware( pylons_app, error_handler, reraise) + # The VCSMiddleware shall operate like a fallback if pyramid doesn't find a + # view to handle the request. Therefore it is wrapped around the pylons + # app. It has to be outside of the error handling otherwise error responses + # from the vcsserver are converted to HTML error pages. This confuses the + # command line tools and the user won't get a meaningful error message. + if vcs_server_enabled: + pylons_app = VCSMiddleware( + pylons_app, settings, appenlight_client, registry=config.registry) + # Convert WSGI app to pyramid view and return it. return wsgiapp(pylons_app)