Skip to content

Commit 5028e5a

Browse files
authored
šŸ› Fix errors observed in front-end due to the HTTP reason attribute and new lines (#7755)
1 parent 7ac9104 commit 5028e5a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

ā€Žservices/web/server/src/simcore_service_webserver/exception_handling/_factory.pyā€Ž

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
_logger = logging.getLogger(__name__)
1515

1616

17-
_STATUS_CODE_TO_HTTP_ERRORS: dict[
18-
int, type[web.HTTPError]
19-
] = get_all_aiohttp_http_exceptions(web.HTTPError)
17+
_STATUS_CODE_TO_HTTP_ERRORS: dict[int, type[web.HTTPError]] = (
18+
get_all_aiohttp_http_exceptions(web.HTTPError)
19+
)
2020

2121

2222
class _DefaultDict(dict):
@@ -40,7 +40,8 @@ def create_error_response(error: ErrorGet, status_code: int) -> web.Response:
4040
return web.json_response(
4141
data={"error": error.model_dump(exclude_unset=True, mode="json")},
4242
dumps=json_dumps,
43-
reason=error.message,
43+
# NOTE: Multiline not allowed in HTTP reason attribute (aiohttp now raises ValueError)
44+
reason=error.message.replace("\n", " ") if error.message else None,
4445
status=status_code,
4546
)
4647

ā€Žservices/web/server/src/simcore_service_webserver/exporter/exceptions.pyā€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ class SDSException(HTTPBadRequest): # pylint: disable=too-many-ancestors
66
"""Basic exception for errors raised inside the module"""
77

88
def __init__(self, message: str):
9-
super().__init__(reason=message)
9+
# Multiline not allowed in HTTP reason attribute
10+
super().__init__(reason=message.replace("\n", " ") if message else None)

0 commit comments

Comments
Ā (0)