Skip to content

Commit

Permalink
Raise a CompsError on installing a nonexistent group/env id
Browse files Browse the repository at this point in the history
Raising ValueError in _group_install() was a mistake, the error that is
expected is CompsError. It will also get caught in install_or_skip(),
which is an unfortunately unreliable interface, but one that we're stuck
with for backwards compatibility.

Raises a CompsError in the same situation in _environment_install() as
well.
  • Loading branch information
Lukáš Hrázký authored and j-mracek committed Sep 4, 2020
1 parent 4d991f6 commit f54a100
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dnf/comps.py
Expand Up @@ -595,6 +595,9 @@ def _removable_grp(self, group_id):
def _environment_install(self, env_id, pkg_types, exclude, strict=True, exclude_groups=None):
assert dnf.util.is_string_type(env_id)
comps_env = self.comps._environment_by_id(env_id)
if not comps_env:
raise CompsError(_("Environment id '%s' does not exist.") % ucd(env_id))

swdb_env = self.history.env.new(env_id, comps_env.name, comps_env.ui_name, pkg_types)
self.history.env.install(swdb_env)

Expand Down Expand Up @@ -663,7 +666,7 @@ def _group_install(self, group_id, pkg_types, exclude=None, strict=True, exclude
assert dnf.util.is_string_type(group_id)
comps_group = self.comps._group_by_id(group_id)
if not comps_group:
raise ValueError(_("Group_id '%s' does not exist.") % ucd(group_id))
raise CompsError(_("Group_id '%s' does not exist.") % ucd(group_id))

swdb_group = self.history.group.new(group_id, comps_group.name, comps_group.ui_name, pkg_types)
for i in comps_group.packages_iter():
Expand Down

0 comments on commit f54a100

Please sign in to comment.