diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index e1978d7cfb..d1e60fd899 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -614,7 +614,11 @@ async def initialize_runtime_config(app: FastAPI): OAuthClientInformationFull(**oauth_client_info), ) except Exception as e: - log.error(f'Error adding OAuth client for MCP tool server {server_id}: {e}') + log.error( + 'Error adding OAuth client for MCP tool server %s: %s', + server_id, + f'{type(e).__name__}: {e}' if str(e) else type(e).__name__, + ) arena_models = await Config.get('evaluation.arena.models', []) or [] if any('access_control' in m.get('meta', {}) for m in arena_models): diff --git a/backend/open_webui/utils/oauth.py b/backend/open_webui/utils/oauth.py index fce053dae8..2f5b6a6d3d 100644 --- a/backend/open_webui/utils/oauth.py +++ b/backend/open_webui/utils/oauth.py @@ -19,7 +19,7 @@ import jwt from authlib.integrations.starlette_client import OAuth from authlib.oauth2.rfc6749.errors import OAuth2Error from authlib.oidc.core import UserInfo -from cryptography.fernet import Fernet +from cryptography.fernet import Fernet, InvalidToken from fastapi import ( HTTPException, status, @@ -279,8 +279,15 @@ def decrypt_data(data: str): try: decrypted = FERNET.decrypt(data.encode()).decode() return JSONCodec.loads(decrypted) + except InvalidToken: + log.error( + 'Error decrypting data: the stored value is not a valid token for the current key. ' + 'If WEBUI_SECRET_KEY or OAUTH_CLIENT_INFO_ENCRYPTION_KEY changed, the affected ' + 'OAuth client must be registered again.' + ) + raise except Exception as e: - log.error(f'Error decrypting data: {e}') + log.error('Error decrypting data: %s: %s', type(e).__name__, e) raise