From 1c4ec8faa356b16edcc31745f595edf45a11d2d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 5 Aug 2024 15:47:57 +0200 Subject: [PATCH] solver/dnf5.py: fix depsolve MarkingErrors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A wrong exception type was returned for the same kind of issues, compared to the DNF4 version. Specifically, the DNF4 version returned `MarkingErrors`, while the DNF5 version returned `DepsolveError`, when a non-existent package was specified in the depsplve request. Make the behavior consistent and return `MarkingErrors` also from the DNF5 version. Signed-off-by: Tomáš Hozza --- osbuild/solver/dnf5.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osbuild/solver/dnf5.py b/osbuild/solver/dnf5.py index 01b0f7a0..5510ce18 100755 --- a/osbuild/solver/dnf5.py +++ b/osbuild/solver/dnf5.py @@ -6,11 +6,12 @@ from typing import List import libdnf5 as dnf5 from libdnf5.base import GoalProblem_NO_PROBLEM as NO_PROBLEM +from libdnf5.base import GoalProblem_NOT_FOUND as NOT_FOUND from libdnf5.common import QueryCmp_CONTAINS as CONTAINS from libdnf5.common import QueryCmp_EQ as EQ from libdnf5.common import QueryCmp_GLOB as GLOB -from osbuild.solver import DepsolveError, RepoError, SolverBase, modify_rootdir_path, read_keys +from osbuild.solver import DepsolveError, MarkingError, RepoError, SolverBase, modify_rootdir_path, read_keys def remote_location(package, schemes=("http", "ftp", "file", "https")): @@ -375,7 +376,11 @@ class DNF5(SolverBase): for pkg in transaction.get("package-specs"): goal.add_install(pkg, settings) transaction = goal.resolve() - if transaction.get_problems() != NO_PROBLEM: + + transaction_problems = transaction.get_problems() + if transaction_problems == NOT_FOUND: + raise MarkingError("\n".join(transaction.get_resolve_logs_as_strings())) + if transaction_problems != NO_PROBLEM: raise DepsolveError("\n".join(transaction.get_resolve_logs_as_strings())) # store the current transaction result