Skip to content

Commit 0ae7055

Browse files
Sai Sridharclaude
andcommitted
Fix calendar _get_valid_token: catch Supabase APIError as ValueError
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0808ba1 commit 0ae7055

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

backend/services/calendar_service.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,13 @@ async def exchange_code(code: str) -> dict:
5050

5151
async def _get_valid_token(user_id: str) -> str:
5252
supabase = get_supabase()
53-
row = supabase.table("user_profiles").select(
54-
"gcal_access_token, gcal_refresh_token, gcal_token_expires_at"
55-
).eq("id", user_id).single().execute()
56-
data = row.data or {}
53+
try:
54+
row = supabase.table("user_profiles").select(
55+
"gcal_access_token, gcal_refresh_token, gcal_token_expires_at"
56+
).eq("id", user_id).single().execute()
57+
data = row.data or {}
58+
except Exception:
59+
raise ValueError("Google Calendar not connected")
5760

5861
access_token = data.get("gcal_access_token")
5962
refresh_tok = data.get("gcal_refresh_token")

0 commit comments

Comments
 (0)