-
Notifications
You must be signed in to change notification settings - Fork 76
Description
Is there an existing issue for this?
- I have searched the existing issues
What happened?
π Bug Report: Two Critical Bugs Fixed in PR
Is there an existing issue for this?
- β I have searched the existing issues
π Issue Overview
This PR fixes TWO separate critical bugs that were breaking the backend:
- Authentication Bug - Missing
awaitkeyword crashes logged-in users - Startup Crash Bug - Weaviate connection failure prevents backend from starting
π Steps to Reproduce
Bug 1: Authentication Crash (dependencies.py)
- Go to
http://localhost:5173/login - Create an account and log in successfully
- Navigate to
/integrationspage - See the error:
AttributeError: 'coroutine' object has no attribute 'user'
Bug 2: Startup Crash (main.py)
- Ensure Weaviate is slow to start or has network issues
- Run
poetry run python main.pyin backend directory - Backend crashes with
httpcore.ConnectTimeouterror - See backend fails to start completely
π― Expected Behavior
Bug 1: Authentication
- Logged-in users should successfully access
/integrationspage - Integration status should load without crashing
- No
AttributeError: 'coroutine'in logs
Bug 2: Startup
- Backend should start even if Weaviate connection times out
- Show warning message instead of crashing
- Other features (Discord bot, API) should work normally
π¨ Actual Behavior
Bug 1: Authentication
AttributeError: 'coroutine' object has no attribute 'user'
INFO: 127.0.0.1:62135 - "GET /v1/integrations/status/discord HTTP/1.1" 401 Unauthorized
Result: Integration page completely broken for logged-in users
Bug 2: Startup
ERROR - Failed to connect to Weaviate: httpcore.ConnectTimeout
Traceback (most recent call last):
File "D:\FSOCIETY\GSOC\Devr.AI\backend\main.py", line 70, in test_weaviate_connection
raise
Result: Backend won't start, all services unavailable
π· Screenshot
Before Fix:
Terminal: Backend crashes during startup
Browser: Cannot access integrations page (if backend somehow starts)
After Fix:
Terminal:
β
Weaviate connection successful OR
β οΈ Failed to connect to Weaviate during startup: [error]
β οΈ Continuing without Weaviate - some features may not work
β
Discord bot logged in as Devr.AI#5824
β
Uvicorn running on http://0.0.0.0:8000
Browser:
β
Integration page loads successfully for logged-in users
β
No AttributeError crashes
π‘ Suggested Improvements (Already Implemented)
Fix 1: Add Missing await Keyword
File: backend/app/core/dependencies.py
Line: 50
# BEFORE (Broken):
user_response = supabase.auth.get_user(token)
# AFTER (Fixed):
user_response = await supabase.auth.get_user(token)Why needed:
- Supabase uses
AsyncClient- all auth methods are async - Without
await, Python tries to access.userattribute before data loads - Bug was introduced by CodeRabbit AI in commit
cedaad3(Oct 16, 2025)
Fix 2: Make Weaviate Connection Non-Blocking
File: backend/main.py
Lines: 68-72
# BEFORE (Broken):
except Exception as e:
logger.error(f"Failed to connect to Weaviate: {e}")
raise # β This crashes entire backend
# AFTER (Fixed):
except Exception as e:
logger.warning(f"Failed to connect to Weaviate during startup: {e}")
logger.warning("Continuing without Weaviate - some features may not work")
# Don't raise - allow backend to start even if Weaviate is unavailableWhy needed:
- Weaviate client tries to connect to PyPI for version checks during init
- Network timeouts or slow connections would crash entire backend
- Backend should gracefully degrade instead of completely failing
- Discord bot, API endpoints, and other services don't depend on Weaviate to start
π Root Cause Analysis
Bug 1: Authentication
Introduced by: CodeRabbit AI automated refactoring
Commit: cedaad3194a4c2fcd7c5d76aa6f096e17db11f78
Date: October 16, 2025
Original correct code: Commit ee34c94 had await keyword
Git history proof:
$ git show cedaad3 backend/app/core/dependencies.py
- user_response = await supabase.auth.get_user(token) # Original (correct)
+ user_response = supabase.auth.get_user(token) # Bug introducedBug 2: Weaviate Startup
Design issue: Original implementation treated Weaviate connection failure as fatal
Problem: Weaviate tries to connect to https://pypi.org/pypi/weaviate-client/json during startup
Result: Network issues or slow connections crash entire backend
Why not caught earlier:
- Weaviate usually starts quickly in Docker
- Most testing done in environments with good network connectivity
- Bug only appears when Weaviate is slow or network has issues
π Impact Assessment
Bug 1: Authentication
Severity: π΄ Critical
Affected users: All logged-in dashboard users
Broken features:
- Integration status page
- Integration management
- Settings page
- Any authenticated API endpoint
Working features (unaffected):
- Discord bot commands
- Public landing page
- User registration
- Login (authentication itself)
Bug 2: Weaviate Startup
Severity: π΄ Critical
Affected users: Everyone (backend won't start)
Broken features:
- Entire backend unavailable
- Discord bot can't connect
- All API endpoints down
- Frontend can't fetch data
Record
- β I agree to follow this project's Code of Conduct
- β I want to work on this issue (already fixed in PR)
Related Files
backend/app/core/dependencies.py- Authentication fixbackend/main.py- Startup robustness fixbackend/app/database/supabase/client.py- AsyncClient usagedocs/issues/ISSUE_002_Missing_Await_In_Auth_Dependency.md- Detailed documentation
References
- Supabase Python AsyncClient: https://supabase.com/docs/reference/python/introduction
- Python Async/Await: https://docs.python.org/3/library/asyncio-task.html
- Weaviate Python Client: https://weaviate.io/developers/weaviate/client-libraries/python
- FastAPI Dependencies: https://fastapi.tiangolo.com/tutorial/dependencies/
Report created by: Om Shukla (@OmShukla-07)
Date: December 1, 2025
Record
- I agree to follow this project's Code of Conduct
- I want to work on this issue