Skip to content

Commit

Permalink
Descriptive error for RPM with invalid metadata
Browse files Browse the repository at this point in the history
https://pulp.plan.io/issues/4424
closes #4424

(cherry picked from commit 800e29c)
  • Loading branch information
fao89 authored and goosemania committed Nov 27, 2019
1 parent 6787c71 commit e896186
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/4424.bugfix
@@ -0,0 +1 @@
Providing a descriptive error message for RPM repos with invalid metadata
16 changes: 14 additions & 2 deletions pulp_rpm/app/tasks/synchronizing.py
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -546,7 +554,11 @@ 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=_("File not found: {filename}").format(
filename=exc.request_info.url))
if results[0].url == package_repodata_urls['primary']:
primary_xml_path = results[0].path
filelists_xml_path = results[1].path
Expand Down

0 comments on commit e896186

Please sign in to comment.