8000 fix: Treat HTTPException as it is, necessary to keep the original status code by takeshi-yashiro · Pull Request #1939 · microsoft/botbuilder-python · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@takeshi-yashiro
Copy link
Contributor
@takeshi-yashiro takeshi-yashiro commented May 17, 2022

#minor

Fixes aiohttp_channel_service_exception_middleware.py changing all HTTP errors turned into 500

Description

This patch fixes aiohttp_channel_service_exception_middleware.py changing all HTTP errors into 500, so that applications can return any other status values, like 400.

The current implementation of aiohttp_channel_service_exception_middleware.py catches all exceptions and raises HTTPInternalServerError instead of the original exception. As this applies to aiohttp.web.HTTPException based exceptions, this prevents application code to status errors other than 500. For example, the following route results in 500 error instead of 400.

from aiohttp import web

async def badreq(request):
    return web.Response(text="BADREQ", status=400)

Specific Changes

In order to avoid this, this patch catches HTTPException and throws as it is. The following two lines are added:

    except HTTPException:
        raise

@takeshi-yashiro takeshi-yashiro requested a review from a team as a code owner May 17, 2022 10:32
@tracyboehrer tracyboehrer changed the title Treat HTTPException as it is, necessary to keep the original status code fix: Treat HTTPException as it is, necessary to keep the original status code Nov 29, 2023
@tracyboehrer tracyboehrer merged commit d6b5e67 into microsoft:main Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0