@@ -344,7 +344,7 @@ def _get_team_name(self, db: Session, team_id: Optional[str]) -> Optional[str]:
344344 """
345345 if not team_id :
346346 return None
347- team = db .query (DbEmailTeam ).filter (DbEmailTeam .id == team_id , DbEmailTeam .enabled .is_ (True )).first ()
347+ team = db .query (DbEmailTeam ).filter (DbEmailTeam .id == team_id , DbEmailTeam .is_active .is_ (True )).first ()
348348 return team .name if team else None
349349
350350 async def register_server (
@@ -412,6 +412,7 @@ async def register_server(
412412 'server_read'
413413 """
414414 try :
415+ logger .info (f"Registering server: { server_in .name } " )
415416 # # Create the new server record.
416417 db_server = DbServer (
417418 name = server_in .name ,
@@ -445,6 +446,7 @@ async def register_server(
445446 if server_in .id :
446447 logger .info (f"Setting custom UUID for server: { server_in .id } " )
447448 db_server .id = server_in .id
449+ logger .info (f"Adding server to DB session: { db_server .name } " )
448450 db .add (db_server )
449451
450452 # Associate tools, verifying each exists using bulk query when multiple items
@@ -467,7 +469,7 @@ async def register_server(
467469
468470 # Associate resources, verifying each exists using bulk query when multiple items
469471 if server_in .associated_resources :
470- resource_ids = [int ( resource_id .strip () ) for resource_id in server_in .associated_resources if resource_id .strip ()]
472+ resource_ids = [resource_id .strip () for resource_id in server_in .associated_resources if resource_id .strip ()]
471473 if len (resource_ids ) > 1 :
472474 # Use bulk query for multiple items
473475 resources = db .execute (select (DbResource ).where (DbResource .id .in_ (resource_ids ))).scalars ().all ()
@@ -479,6 +481,11 @@ async def register_server(
479481 elif resource_ids :
480482 # Use single query for single item (maintains test compatibility)
481483 resource_obj = db .get (DbResource , resource_ids [0 ])
484+ # for resource_id in server_in.associated_resources:
485+ # if resource_id.strip() == "":
486+ # continue
487+ # # Resource IDs are stored as string UUID hex values, not integers.
488+ # resource_obj = db.get(DbResource, resource_id)
482489 if not resource_obj :
483490 raise ServerError (f"Resource with id { resource_ids [0 ]} does not exist." )
484491 db_server .resources .append (resource_obj )
@@ -884,7 +891,7 @@ async def update_server(
884891 if server_update .associated_resources is not None :
885892 server .resources = []
886893 if server_update .associated_resources :
887- resource_ids = [int ( resource_id ) for resource_id in server_update .associated_resources if resource_id ]
894+ resource_ids = [resource_id for resource_id in server_update .associated_resources if resource_id ]
888895 if resource_ids :
889896 resources = db .execute (select (DbResource ).where (DbResource .id .in_ (resource_ids ))).scalars ().all ()
890897 server .resources = list (resources )
@@ -893,7 +900,7 @@ async def update_server(
893900 if server_update .associated_prompts is not None :
894901 server .prompts = []
895902 if server_update .associated_prompts :
896- prompt_ids = [int ( prompt_id ) for prompt_id in server_update .associated_prompts if prompt_id ]
903+ prompt_ids = [prompt_id for prompt_id in server_update .associated_prompts if prompt_id ]
897904 if prompt_ids :
898905 prompts = db .execute (select (DbPrompt ).where (DbPrompt .id .in_ (prompt_ids ))).scalars ().all ()
899906 server .prompts = list (prompts )
@@ -1025,7 +1032,7 @@ async def toggle_server_status(self, db: Session, server_id: str, activate: bool
10251032 "associated_resources" : [res .id for res in server .resources ],
10261033 "associated_prompts" : [prompt .id for prompt in server .prompts ],
10271034 }
1028- logger .debug (f"Server Data: { server_data } " )
1035+ logger .info (f"Server Data: { server_data } " )
10291036 return self ._convert_server_to_read (server )
10301037 except PermissionError as e :
10311038 raise e
0 commit comments