Skip to content

Commit 04789d8

Browse files
authored
Merge pull request IBM#1487 from gabe-l-hart/TeamIdDict-1486
fix: Handle the case where the `teams` list is a list of dicts
2 parents e61b340 + 59f9d79 commit 04789d8

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

mcpgateway/admin.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8784,18 +8784,12 @@ async def admin_metrics_partial_html(
87848784
Raises:
87858785
HTTPException: If entity_type is not one of the valid types
87868786
"""
8787-
LOGGER.debug(
8788-
f"User {get_user_email(user)} requested metrics partial "
8789-
f"(entity_type={entity_type}, page={page}, per_page={per_page})"
8790-
)
8787+
LOGGER.debug(f"User {get_user_email(user)} requested metrics partial " f"(entity_type={entity_type}, page={page}, per_page={per_page})")
87918788

87928789
# Validate entity type
87938790
valid_types = ["tools", "resources", "prompts", "servers"]
87948791
if entity_type not in valid_types:
8795-
raise HTTPException(
8796-
status_code=400,
8797-
detail=f"Invalid entity_type. Must be one of: {', '.join(valid_types)}"
8798-
)
8792+
raise HTTPException(status_code=400, detail=f"Invalid entity_type. Must be one of: {', '.join(valid_types)}")
87998793

88008794
# Constrain parameters
88018795
page = max(1, page)

mcpgateway/auth.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ async def get_team_from_token(payload: Dict[str, Any], db: Session) -> Optional[
103103
>>> del sys.modules["mcpgateway.services.team_management_service"]
104104
"""
105105
team_id = payload.get("teams")[0] if payload.get("teams") else None
106+
if isinstance(team_id, dict):
107+
team_id = team_id.get("id")
106108
user_email = payload.get("sub")
109+
107110
# If no team found in token, get user's personal team
108111
if not team_id:
109112

0 commit comments

Comments
 (0)