From 5b8c5d52dac47d2aea6219a17faba3f39df67403 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Wed, 14 Dec 2022 19:09:01 +0100 Subject: [PATCH 1/2] fix: no stack trace for http errors --- lnbits/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lnbits/app.py b/lnbits/app.py index 060e07e38..3ee3da347 100644 --- a/lnbits/app.py +++ b/lnbits/app.py @@ -174,6 +174,8 @@ def register_exception_handlers(app: FastAPI): etype, _, tb = sys.exc_info() traceback.print_exception(etype, exc, tb) logger.error(f"Exception: {str(exc)}") + # Only the browser sends "text/html" request + # not fail proof, but everything else get's a JSON response if ( request.headers and "accept" in request.headers @@ -215,8 +217,6 @@ def register_exception_handlers(app: FastAPI): @app.exception_handler(HTTPException) async def http_exception_handler(request: Request, exc: HTTPException): - etype, _, tb = sys.exc_info() - traceback.print_exception(etype, exc, tb) logger.error(f"HTTPException {exc.status_code}: {exc.detail}") # Only the browser sends "text/html" request # not fail proof, but everything else get's a JSON response From 78f94483d05d2d72e9eb32aaa5500e6c504499fc Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Wed, 14 Dec 2022 19:10:26 +0100 Subject: [PATCH 2/2] fix: no stacktrace for validartion errors --- lnbits/app.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lnbits/app.py b/lnbits/app.py index 3ee3da347..fccfffd1b 100644 --- a/lnbits/app.py +++ b/lnbits/app.py @@ -194,8 +194,6 @@ def register_exception_handlers(app: FastAPI): async def validation_exception_handler( request: Request, exc: RequestValidationError ): - etype, _, tb = sys.exc_info() - traceback.print_exception(etype, exc, tb) logger.error(f"RequestValidationError: {str(exc)}") # Only the browser sends "text/html" request # not fail proof, but everything else get's a JSON response