1818from models_library .services_types import ServiceKey , ServiceVersion
1919from models_library .users import UserID
2020from pydantic import HttpUrl , NonNegativeInt
21+ from servicelib .logging_errors import (
22+ create_troubleshotting_log_kwargs ,
23+ )
2124from servicelib .rabbitmq .rpc_interfaces .catalog .errors import (
2225 CatalogForbiddenError ,
26+ CatalogInconsistentError ,
2327 CatalogItemNotFoundError ,
2428)
2529
@@ -149,7 +153,7 @@ async def list_latest_services(
149153 product_name = product_name ,
150154 )
151155
152- # get manifest of those with access rights
156+ # Get manifest of those with access rights
153157 got = await manifest .get_batch_services (
154158 [
155159 (sc .key , sc .version )
@@ -164,10 +168,27 @@ async def list_latest_services(
164168 if isinstance (sc , ServiceMetaDataPublished )
165169 }
166170
167- # FIXME: services (key, version) matches not found in manifest means that they are in the database but they
168- # do not really exist in the service. We cannot include them but we should definitively warn!!
169- # All services in database should be include in the registry. The background task should be responsible of that
171+ # Log a warning for missing services
172+ missing_services = [
173+ (sc .key , sc .version )
174+ for sc in services
175+ if (sc .key , sc .version ) not in service_manifest
176+ ]
177+ if missing_services :
178+ msg = f"Found { len (missing_services )} services that are in the database but missing in the registry manifest"
179+ _logger .warning (
180+ ** create_troubleshotting_log_kwargs (
181+ msg ,
182+ error = CatalogInconsistentError (
183+ missing_services = missing_services ,
184+ user_id = user_id ,
185+ product_name = product_name ,
186+ ),
187+ tip = "This might be due to malfunction of the background-task or that this call was done while the sync was taking place" ,
188+ )
189+ )
170190
191+ # Aggregate the services manifest and access-rights
171192 items = [
172193 _to_latest_get_schema (
173194 service_db = sc ,
0 commit comments