diff --git a/CHANGES/4424.misc b/CHANGES/4424.misc new file mode 100644 index 0000000000..85f05a6e91 --- /dev/null +++ b/CHANGES/4424.misc @@ -0,0 +1 @@ +Providing a descriptive error message for RPM repos with invalid metadata diff --git a/pulp_rpm/app/tasks/synchronizing.py b/pulp_rpm/app/tasks/synchronizing.py index 6cf1877f62..95c61cbb2d 100644 --- a/pulp_rpm/app/tasks/synchronizing.py +++ b/pulp_rpm/app/tasks/synchronizing.py @@ -8,7 +8,8 @@ from gettext import gettext as _ # noqa:F401 from urllib.parse import urljoin -from aiohttp import ClientResponseError +from aiohttp.client_exceptions import ClientResponseError +from aiohttp.web_exceptions import HTTPNotFound import createrepo_c as cr import libcomps @@ -344,9 +345,11 @@ async def run(self): optionalgroup_to_environments = defaultdict(list) modulemd_results = None comps_downloader = None + main_types = set() for record in repomd.records: if record.type in PACKAGE_REPODATA: + main_types.update([record.type]) package_repodata_urls[record.type] = urljoin(remote_url, record.location_href) elif record.type in UPDATE_REPODATA: @@ -383,6 +386,11 @@ async def run(self): dc = DeclarativeContent(content=repo_metadata_file, d_artifacts=[da]) await self.put(dc) + missing_type = set(PACKAGE_REPODATA) - main_types + if missing_type: + raise FileNotFoundError(_("XML file(s): {filename} not found".format( + filename=", ".join(missing_type)))) + # we have to sync module.yaml first if it exists, to make relations to packages if modulemd_results: modulemd_index = mmdlib.ModuleIndex.new() @@ -546,7 +554,10 @@ async def run(self): while pending: done, pending = await asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED) for downloader in done: - results = downloader.result() + try: + results = downloader.result() + except ClientResponseError as exc: + raise HTTPNotFound(reason=f"File not found: {exc.request_info.url}") if results[0].url == package_repodata_urls['primary']: primary_xml_path = results[0].path filelists_xml_path = results[1].path