Merge pull request #219 from christianlouis/copilot/fix-internal-server-error

Fix silent 500s in Google OAuth: log full tracebacks
This commit is contained in:
Christian Krakau-Louis
2026-05-03 21:16:24 +02:00
committed by GitHub
3 changed files with 96 additions and 71 deletions
+7
View File
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- version list --> <!-- version list -->
## [Unreleased]
### Fixed
- OAuth Google sign-in: added `exc_info=True` to the catch-all exception handler in `auth_service.py` so the full traceback is always emitted to the log instead of only `str(e)`.
- OAuth Google sign-in: added an endpoint-level try/except in the `/auth/google` handler to catch and log any unexpected errors (e.g. database failures) that occurred after the Google token exchange, which previously surfaced as silent 500s.
## v0.8.1 (2026-05-03) ## v0.8.1 (2026-05-03)
### Bug Fixes ### Bug Fixes
+14
View File
@@ -187,6 +187,7 @@ async def google_oauth(
auth_request.redirect_uri, auth_request.redirect_uri,
) )
try:
# Get user info from Google # Get user info from Google
user_info = await oauth_service.get_google_user_info( user_info = await oauth_service.get_google_user_info(
code=auth_request.code, redirect_uri=auth_request.redirect_uri code=auth_request.code, redirect_uri=auth_request.redirect_uri
@@ -270,6 +271,19 @@ async def google_oauth(
OAUTH_CALLBACKS_TOTAL.labels(provider="google", status="success").inc() OAUTH_CALLBACKS_TOTAL.labels(provider="google", status="success").inc()
return tokens return tokens
except HTTPException:
raise
except Exception:
OAUTH_CALLBACKS_TOTAL.labels(provider="google", status="error").inc()
logger.error(
"OAuth [Google sign-in]: unhandled error during sign-in flow",
exc_info=True,
)
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="OAuth authentication failed",
)
@router.get("/google/authorize-url") @router.get("/google/authorize-url")
async def get_google_authorize_url(redirect_uri: str): async def get_google_authorize_url(redirect_uri: str):
+5 -1
View File
@@ -142,7 +142,11 @@ class OAuthService:
except HTTPException: except HTTPException:
raise raise
except Exception as e: except Exception as e:
logger.error("OAuth [Google sign-in]: unexpected error: %s", e) logger.error(
"OAuth [Google sign-in]: unexpected error: %s",
e,
exc_info=True,
)
raise HTTPException( raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="OAuth authentication failed", detail="OAuth authentication failed",