Skip to content

Commit 54f9bcd

Browse files
authored
🐛 Fixes bad formatting while handling missing configuration errors (#6501)
1 parent 997eeb3 commit 54f9bcd

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

packages/service-library/src/servicelib/aiohttp/rest_middlewares.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
from .typing_extension import Handler, Middleware
3232

3333
DEFAULT_API_VERSION = "v0"
34-
FMSG_INTERNAL_ERROR_USER_FRIENDLY = "We apologize for the inconvenience. Our team has recorded the issue and is working to resolve it as quickly as possible. Thank you for your patience [{}]"
34+
_FMSG_INTERNAL_ERROR_USER_FRIENDLY_WITH_OEC = (
35+
"We apologize for the inconvenience."
36+
" Our team has recorded the issue [{error_code}] and is working to resolve it as quickly as possible."
37+
" Thank you for your patience"
38+
)
3539

3640

3741
_logger = logging.getLogger(__name__)
@@ -58,7 +62,9 @@ def _process_and_raise_unexpected_error(request: web.BaseRequest, err: Exception
5862
if isinstance(err, OsparcErrorMixin):
5963
error_context.update(err.error_context())
6064

61-
frontend_msg = FMSG_INTERNAL_ERROR_USER_FRIENDLY.format(error_code)
65+
frontend_msg = _FMSG_INTERNAL_ERROR_USER_FRIENDLY_WITH_OEC.format(
66+
error_code=error_code
67+
)
6268
log_msg = create_troubleshotting_log_message(
6369
message_to_user=frontend_msg,
6470
error=err,

packages/service-library/tests/aiohttp/test_rest_middlewares.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from models_library.utils.json_serialization import json_dumps
1717
from servicelib.aiohttp import status
1818
from servicelib.aiohttp.rest_middlewares import (
19-
FMSG_INTERNAL_ERROR_USER_FRIENDLY,
19+
_FMSG_INTERNAL_ERROR_USER_FRIENDLY_WITH_OEC,
2020
envelope_middleware_factory,
2121
error_middleware_factory,
2222
)
@@ -238,7 +238,10 @@ async def test_raised_unhandled_exception(
238238
# user friendly message with OEC reference
239239
assert "OEC" in error["message"]
240240
parsed_oec = parse_error_code(error["message"]).pop()
241-
assert FMSG_INTERNAL_ERROR_USER_FRIENDLY.format(parsed_oec) == error["message"]
241+
assert (
242+
_FMSG_INTERNAL_ERROR_USER_FRIENDLY_WITH_OEC.format(error_code=parsed_oec)
243+
== error["message"]
244+
)
242245

243246
# avoids details
244247
assert not error.get("errors")

services/web/server/src/simcore_service_webserver/users/_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def wrapper(request: web.Request) -> web.StreamResponse:
5454
raise web.HTTPNotFound(reason=f"{exc}") from exc
5555
except MissingGroupExtraPropertiesForProductError as exc:
5656
error_code = create_error_code(exc)
57-
frontend_msg = FMSG_MISSING_CONFIG_WITH_OEC.format(error_code)
57+
frontend_msg = FMSG_MISSING_CONFIG_WITH_OEC.format(error_code=error_code)
5858
log_msg = create_troubleshotting_log_message(
5959
message_to_user=frontend_msg,
6060
error=exc,

services/web/server/tests/unit/with_dbs/03/test_users.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ async def test_get_profile_with_failing_db_connection(
196196

197197
resp = await client.get(url.path)
198198

199-
await assert_status(resp, expected)
199+
data, error = await assert_status(resp, expected)
200+
assert not data
201+
assert error["message"] == "Authentication service is temporary unavailable"
200202

201203

202204
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)