Repository repair aborts when locally missing RPM file is no longer available upstream

Problem:
Running a repository repair cause local RPMs are missing in the /v/l/pulp/media/artifact directory. Unfortunately, it aborts with an exception:

pulp: backoff:ERROR: Giving up _run(…) after 1 tries (aiohttp.client_exceptions.ClientResponseError: 404, message=‘Not Found’, url=URL(‘https://repos.fedorapeople.org/repos/pulp/pulp/stable/2.21/7/x86_64/python-nectar-1.6.2-1.el7.noarch.rpm’))

Apparently the upstream repo is removing outdated RPMs but it is still in our local database. Its also missing from our local directory so it looks like the repair is trying to download it again, but can’t find it.

Expected outcome:
The repair to pull the new metadata, analyze it, figure out that the RPM in question is no longer available in upstream and then not try to download it, finishing the repair without errors.

Foreman and Proxy versions:
Foreman 2.3.1
Katello 3.18.1

Foreman and Proxy plugin versions:

Distribution and version:
CentOS 7.9

Other relevant data:
Repo has been created with “Mirror on sync: yes”.

I would also suggest that the repair will generate new metadata at the end, so you don’t need to do this manually.