@@ -322,7 +322,14 @@ async def remove_project(
322322 ) # pragma: no cover
323323
324324 # Check if trying to delete the default project
325- if name == project_service .default_project :
325+ # In cloud mode, database is source of truth; in local mode, check config
326+ config_default = project_service .default_project
327+ db_default = await project_service .repository .get_default_project ()
328+
329+ # Use database default if available, otherwise fall back to config default
330+ default_project_name = db_default .name if db_default else config_default
331+
332+ if name == default_project_name :
326333 available_projects = await project_service .list_projects ()
327334 other_projects = [p .name for p in available_projects if p .name != name ]
328335 detail = f"Cannot delete default project '{ name } '. "
@@ -418,8 +425,13 @@ async def get_default_project(
418425 Returns:
419426 Response with project default information
420427 """
421- # Get the old default project
422- default_name = project_service .default_project
428+ # Get the default project
429+ # In cloud mode, database is source of truth; in local mode, check config
430+ config_default = project_service .default_project
431+ db_default = await project_service .repository .get_default_project ()
432+
433+ # Use database default if available, otherwise fall back to config default
434+ default_name = db_default .name if db_default else config_default
423435 default_project = await project_service .get_project (default_name )
424436 if not default_project : # pragma: no cover
425437 raise HTTPException ( # pragma: no cover
0 commit comments