-
Notifications
You must be signed in to change notification settings - Fork 615
[BUG][TEAMS]: list_teams uses current_user_ctx["db"] which is always None #2608
Copy link
Copy link
Closed
Labels
SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releaseP2: Important but not vital; high-value items that are not crucial for the immediate releasebugSomething isn't workingSomething isn't workingpythonPython / backend development (FastAPI)Python / backend development (FastAPI)
Milestone
Description
Bug Summary
The GET /teams endpoint returns 500 error because it uses current_user_ctx["db"] which is always None. The get_current_user_with_permissions function explicitly returns "db": None with the comment "Session closed; use endpoint's db param instead", but the teams router doesn't follow this pattern.
Affected Component
mcpgateway/routers/teams.py-list_teams()function (line 143)
Root Cause
Line 143 in teams.py:
db = current_user_ctx["db"] # This is always None!The get_current_user_with_permissions function in rbac.py returns:
"db": None, # Session closed; use endpoint's db param insteadError Message
mcpgateway.routers.teams - ERROR - Error listing teams: 'NoneType' object has no attribute 'execute'
Steps to Reproduce
TOKEN=$(python -m mcpgateway.utils.create_jwt_token --username admin@example.com --exp 60 --secret "$JWT_SECRET")
curl -X GET "http://localhost:8080/teams/" -H "Authorization: Bearer $TOKEN"Expected Behavior
Returns list of teams.
Actual Behavior
Returns 500 with {"detail":"Failed to list teams"}
Fix
Add db: Session = Depends(get_db) as a parameter to list_teams() and use it directly instead of extracting from current_user_ctx.
Discovered During
Locust load testing with TeamsUser class.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releaseP2: Important but not vital; high-value items that are not crucial for the immediate releasebugSomething isn't workingSomething isn't workingpythonPython / backend development (FastAPI)Python / backend development (FastAPI)