From 61bbb99d9e99c69177f1f0230f730fc512b5b293 Mon Sep 17 00:00:00 2001 From: "Ethan T." Date: Mon, 9 Mar 2026 05:36:53 +0800 Subject: [PATCH] fix: replace bare except with Exception in oauth.py (#22420) * fix: replace bare except with except Exception in main.py * fix: replace bare except with Exception in oauth.py In Python 3, bare 'except:' is discouraged as it catches all SystemExit and KeyboardInterrupt exceptions. Changed to 'except Exception:' to only catch actual exceptions. --- backend/open_webui/main.py | 4 ++-- backend/open_webui/utils/oauth.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 4c27e811cb..202bd32c1d 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1864,7 +1864,7 @@ async def chat_completion( "model": model_id, }, ) - except: + except Exception: pass ctx = build_chat_response_context( @@ -1911,7 +1911,7 @@ async def chat_completion( {"type": "chat:tasks:cancel"}, ) - except: + except Exception: pass finally: try: diff --git a/backend/open_webui/utils/oauth.py b/backend/open_webui/utils/oauth.py index 392ae74f96..249cc62d74 100644 --- a/backend/open_webui/utils/oauth.py +++ b/backend/open_webui/utils/oauth.py @@ -620,7 +620,7 @@ class OAuthClientManager: payload = json.loads(response_text) error = payload.get("error") error_description = payload.get("error_description", "") - except: + except Exception: pass else: error_description = response_text