osbuild / osbuild

Build-Pipelines for Operating System Artifacts

Home Page:https://www.osbuild.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raise exception for misconfigured repos in osbuild-depsolve-mpp

achilleas-k opened this issue · comments

When a repository is not configured properly, it can lead to the following uninformative assertion error:

if "name" in desc:
repo.name = desc["name"]
if "baseurl" in desc:
repo.baseurl = desc["baseurl"]
elif "metalink" in desc:
repo.metalink = desc["metalink"]
elif "mirrorlist" in desc:
repo.mirrorlist = desc["mirrorlist"]
else:
assert False

Let's make a typed exception for this and return a structured error with a message that's more useful for a user that might get it.

We should actually be catching this error before it reaches the depsolver, but it'd be good to have it here too.

Perhaps an unpopular opinion but removing the assertion here will likely lead to a more descriptive exception when the dict is getting used (probably a KeyError) :)