fix: say why OAuth client data failed to decrypt instead of logging an empty error

This commit is contained in:
silentoplayz 2026-08-16 14:49:50 -04:00
parent 31d08d592c
commit 6a9620611e
2 changed files with 14 additions and 3 deletions

View file

@ -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):

View file

@ -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