@@ -3749,14 +3749,7 @@ def _get_due_gateway_lifecycle_ids(self) -> List[str]:
37493749 claim_filter = or_ (DbGateway .lifecycle_claim_expires_at .is_ (None ), DbGateway .lifecycle_claim_expires_at <= now )
37503750 deleting_ids = db .execute (select (DbGateway .id ).where (DbGateway .status == "deleting" ).where (claim_filter )).scalars ().all ()
37513751 pending_ids = (
3752- db .execute (
3753- select (DbGateway .id )
3754- .where (DbGateway .status == "pending" )
3755- .where (or_ (DbGateway .next_retry_at .is_ (None ), DbGateway .next_retry_at <= now ))
3756- .where (claim_filter )
3757- )
3758- .scalars ()
3759- .all ()
3752+ db .execute (select (DbGateway .id ).where (DbGateway .status == "pending" ).where (or_ (DbGateway .next_retry_at .is_ (None ), DbGateway .next_retry_at <= now )).where (claim_filter )).scalars ().all ()
37603753 )
37613754 return [* deleting_ids , * (f"pending:{ gateway_id } " for gateway_id in pending_ids )]
37623755
@@ -4933,6 +4926,7 @@ async def _run_health_checks(self, user_email: str) -> None:
49334926 while True :
49344927 try :
49354928 if self ._redis_client and settings .cache_type == "redis" :
4929+
49364930 async def require_redis_leader () -> bool :
49374931 """Check for redis leader"""
49384932 current_leader = await self ._redis_client .get (self ._leader_key )
@@ -5572,9 +5566,7 @@ def _created_via_allowed(created_via: Optional[str]) -> bool:
55725566
55735567 stale_resource_ids = []
55745568 if not skip_stale_cleanup and catalog_sync .new_resource_uris is not None :
5575- stale_resource_ids = [
5576- resource .id for resource in gateway .resources if resource .uri not in catalog_sync .new_resource_uris and _created_via_allowed (getattr (resource , "created_via" , None ))
5577- ]
5569+ stale_resource_ids = [resource .id for resource in gateway .resources if resource .uri not in catalog_sync .new_resource_uris and _created_via_allowed (getattr (resource , "created_via" , None ))]
55785570 if stale_resource_ids :
55795571 for i in range (0 , len (stale_resource_ids ), 500 ):
55805572 chunk = stale_resource_ids [i : i + 500 ]
@@ -5585,9 +5577,7 @@ def _created_via_allowed(created_via: Optional[str]) -> bool:
55855577
55865578 stale_prompt_ids = []
55875579 if not skip_stale_cleanup and catalog_sync .new_prompt_names is not None :
5588- stale_prompt_ids = [
5589- prompt .id for prompt in gateway .prompts if prompt .original_name not in catalog_sync .new_prompt_names and _created_via_allowed (getattr (prompt , "created_via" , None ))
5590- ]
5580+ stale_prompt_ids = [prompt .id for prompt in gateway .prompts if prompt .original_name not in catalog_sync .new_prompt_names and _created_via_allowed (getattr (prompt , "created_via" , None ))]
55915581 if stale_prompt_ids :
55925582 for i in range (0 , len (stale_prompt_ids ), 500 ):
55935583 chunk = stale_prompt_ids [i : i + 500 ]
@@ -5601,13 +5591,9 @@ def _created_via_allowed(created_via: Optional[str]) -> bool:
56015591 if not skip_stale_cleanup :
56025592 gateway .tools = [tool for tool in gateway .tools if tool .original_name in catalog_sync .new_tool_names or not _created_via_allowed (getattr (tool , "created_via" , None ))]
56035593 if catalog_sync .new_resource_uris is not None :
5604- gateway .resources = [
5605- resource for resource in gateway .resources if resource .uri in catalog_sync .new_resource_uris or not _created_via_allowed (getattr (resource , "created_via" , None ))
5606- ]
5594+ gateway .resources = [resource for resource in gateway .resources if resource .uri in catalog_sync .new_resource_uris or not _created_via_allowed (getattr (resource , "created_via" , None ))]
56075595 if catalog_sync .new_prompt_names is not None :
5608- gateway .prompts = [
5609- prompt for prompt in gateway .prompts if prompt .original_name in catalog_sync .new_prompt_names or not _created_via_allowed (getattr (prompt , "created_via" , None ))
5610- ]
5596+ gateway .prompts = [prompt for prompt in gateway .prompts if prompt .original_name in catalog_sync .new_prompt_names or not _created_via_allowed (getattr (prompt , "created_via" , None ))]
56115597
56125598 tools_removed = len (stale_tool_ids )
56135599 resources_removed = len (stale_resource_ids )
@@ -5819,7 +5805,7 @@ async def _refresh_gateway_tools_resources_prompts(
58195805 _refresh_key = _enc .decrypt_secret_or_plaintext (_refresh_key )
58205806 except Exception :
58215807 logger .debug ("client_key decryption skipped during gateway refresh" )
5822- _capabilities , tools , resources , prompts , _ = await self ._initialize_gateway (
5808+ _capabilities , tools , resources , prompts , validation_errors = await self ._initialize_gateway (
58235809 url = gateway_url ,
58245810 authentication = gateway_auth_value ,
58255811 transport = gateway_transport ,
@@ -5839,6 +5825,8 @@ async def _refresh_gateway_tools_resources_prompts(
58395825 result ["error" ] = str (e )
58405826 return result
58415827
5828+ result ["validation_errors" ] = validation_errors
5829+
58425830 # For authorization_code OAuth gateways, empty responses may indicate incomplete auth flow
58435831 # Skip only if it's an auth_code gateway with no data (user may not have completed authorization)
58445832 is_auth_code_gateway = gateway_oauth_config and isinstance (gateway_oauth_config , dict ) and gateway_oauth_config .get ("grant_type" ) == "authorization_code"
0 commit comments