From b6ec9fc5427bf9243a6084ed344b12cb61fe4247 Mon Sep 17 00:00:00 2001 From: Krishan Patel Date: Wed, 15 Apr 2026 15:27:51 +0100 Subject: [PATCH 1/3] . --- core/api/middleware/exception_handling_middleware.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/api/middleware/exception_handling_middleware.py b/core/api/middleware/exception_handling_middleware.py index 85bb769..1b15369 100644 --- a/core/api/middleware/exception_handling_middleware.py +++ b/core/api/middleware/exception_handling_middleware.py @@ -12,9 +12,10 @@ class ExceptionHandlingMiddleware(BaseHTTPMiddleware): - def __init__(self, app: ASGIApp, shouldSquashClientExceptions: bool = True) -> None: + def __init__(self, app: ASGIApp, shouldSquashClientExceptions: bool = True, shouldHideInternalErrors: bool = True) -> None: super().__init__(app=app) self.shouldSquashClientExceptions = shouldSquashClientExceptions + self.shouldHideInternalErrors = shouldHideInternalErrors @staticmethod def _convert_exception(exception: KibaException) -> Response: @@ -41,5 +42,8 @@ async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) - response = self._convert_exception(exception=exception) except Exception as exception: # noqa: BLE001 logging.exception(exception) - response = self._convert_exception(exception=KibaException.from_exception(exception=exception)) + kibaException = KibaException.from_exception(exception=exception) + if self.shouldHideInternalErrors: + kibaException = KibaException(message='Internal Server Error', statusCode=kibaException.statusCode) + response = self._convert_exception(exception=kibaException) return response From 7e9028ebbdd33b1084520a02077ec10af1f71703 Mon Sep 17 00:00:00 2001 From: Krishan Patel Date: Wed, 15 Apr 2026 15:35:34 +0100 Subject: [PATCH 2/3] . --- core/api/middleware/exception_handling_middleware.py | 2 ++ uv.lock | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/api/middleware/exception_handling_middleware.py b/core/api/middleware/exception_handling_middleware.py index 1b15369..4e48fe0 100644 --- a/core/api/middleware/exception_handling_middleware.py +++ b/core/api/middleware/exception_handling_middleware.py @@ -39,6 +39,8 @@ async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) - response = self._convert_exception(exception=exception) except KibaException as exception: logging.exception(exception) + if self.shouldHideInternalErrors: + exception = KibaException(message='Internal Server Error', statusCode=exception.statusCode) response = self._convert_exception(exception=exception) except Exception as exception: # noqa: BLE001 logging.exception(exception) diff --git a/uv.lock b/uv.lock index 09f66ce..7b72458 100644 --- a/uv.lock +++ b/uv.lock @@ -2,10 +2,6 @@ version = 1 revision = 3 requires-python = ">=3.12, <4" -[options] -exclude-newer = "2026-03-29T09:26:57.277657Z" -exclude-newer-span = "P7D" - [[package]] name = "aiobotocore" version = "3.3.0" From 4924143efa200c6a0ccce877da79e04c70344c8d Mon Sep 17 00:00:00 2001 From: Krishan Patel Date: Wed, 15 Apr 2026 15:36:27 +0100 Subject: [PATCH 3/3] . --- core/api/middleware/exception_handling_middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/api/middleware/exception_handling_middleware.py b/core/api/middleware/exception_handling_middleware.py index 4e48fe0..a372f72 100644 --- a/core/api/middleware/exception_handling_middleware.py +++ b/core/api/middleware/exception_handling_middleware.py @@ -40,7 +40,7 @@ async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) - except KibaException as exception: logging.exception(exception) if self.shouldHideInternalErrors: - exception = KibaException(message='Internal Server Error', statusCode=exception.statusCode) + exception = KibaException(message='Internal Server Error', statusCode=exception.statusCode, exceptionType=exception.exceptionType) response = self._convert_exception(exception=exception) except Exception as exception: # noqa: BLE001 logging.exception(exception)