Skip to content

Commit f8d64f4

Browse files
Sai Sridharclaude
andcommitted
Fix 500 errors on status endpoints — catch Supabase column errors gracefully
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4776987 commit f8d64f4

3 files changed

Lines changed: 34 additions & 22 deletions

File tree

backend/routes/calendar.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,15 @@ async def calendar_callback(
7575

7676
@router.get("/status")
7777
async def calendar_status(current_user: Annotated[dict, Depends(get_current_user)]):
78-
supabase = get_supabase()
79-
row = supabase.table("user_profiles").select(
80-
"gcal_connected"
81-
).eq("id", _uid(current_user)).single().execute()
82-
data = row.data or {}
83-
return {"connected": bool(data.get("gcal_connected"))}
78+
try:
79+
supabase = get_supabase()
80+
row = supabase.table("user_profiles").select(
81+
"gcal_connected"
82+
).eq("id", _uid(current_user)).single().execute()
83+
data = row.data or {}
84+
return {"connected": bool(data.get("gcal_connected"))}
85+
except Exception:
86+
return {"connected": False}
8487

8588

8689
@router.get("/events")

backend/routes/crm_integrations.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@ class SalesforceSaveBody(BaseModel):
3434
@router.get("/hubspot/status")
3535
async def hubspot_status(current_user: Annotated[dict, Depends(get_current_user)]):
3636
uid = current_user["id"]
37-
supabase = get_supabase()
38-
row = supabase.table("user_profiles").select("hubspot_connected, hubspot_api_key").eq("id", uid).single().execute()
39-
data = row.data or {}
40-
return {
41-
"connected": bool(data.get("hubspot_connected")),
42-
"has_key": bool(data.get("hubspot_api_key")),
43-
}
37+
try:
38+
supabase = get_supabase()
39+
row = supabase.table("user_profiles").select("hubspot_connected, hubspot_api_key").eq("id", uid).single().execute()
40+
data = row.data or {}
41+
return {
42+
"connected": bool(data.get("hubspot_connected")),
43+
"has_key": bool(data.get("hubspot_api_key")),
44+
}
45+
except Exception:
46+
return {"connected": False, "has_key": False}
4447

4548

4649
@router.post("/hubspot/connect")
@@ -94,9 +97,12 @@ async def hubspot_disconnect(current_user: Annotated[dict, Depends(get_current_u
9497
@router.get("/salesforce/status")
9598
async def salesforce_status(current_user: Annotated[dict, Depends(get_current_user)]):
9699
uid = current_user["id"]
97-
supabase = get_supabase()
98-
row = supabase.table("user_profiles").select("sf_connected, sf_username").eq("id", uid).single().execute()
99-
data = row.data or {}
100+
try:
101+
supabase = get_supabase()
102+
row = supabase.table("user_profiles").select("sf_connected, sf_username").eq("id", uid).single().execute()
103+
data = row.data or {}
104+
except Exception:
105+
return {"connected": False, "username": None}
100106
return {
101107
"connected": bool(data.get("sf_connected")),
102108
"username": data.get("sf_username"),

backend/routes/outlook.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,15 @@ async def outlook_callback(
7474
@router.get("/status")
7575
async def outlook_status(current_user: Annotated[dict, Depends(get_current_user)]):
7676
"""Return Outlook connection status."""
77-
supabase = get_supabase()
78-
row = supabase.table("user_profiles").select(
79-
"ms_connected, ms_email"
80-
).eq("id", _uid(current_user)).single().execute()
81-
data = row.data or {}
82-
return {"connected": bool(data.get("ms_connected")), "email": data.get("ms_email")}
77+
try:
78+
supabase = get_supabase()
79+
row = supabase.table("user_profiles").select(
80+
"ms_connected, ms_email"
81+
).eq("id", _uid(current_user)).single().execute()
82+
data = row.data or {}
83+
return {"connected": bool(data.get("ms_connected")), "email": data.get("ms_email")}
84+
except Exception:
85+
return {"connected": False, "email": None}
8386

8487

8588
@router.post("/sync")

0 commit comments

Comments
 (0)