Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnf history list and dnf history info do not return non-zero exit status when transactions not found for package failure occurs #2213

Open
danehlim opened this issue Feb 11, 2025 · 0 comments · May be fixed by #2214

Comments

@danehlim
Copy link

danehlim commented Feb 11, 2025

Summary

dnf history subcommands list and info do not return non-zero exit status when they fail to find transactions for a specified package/<package-name-spec>. This is a bug or undocumented behavior change relative to the corresponding yum history package-list and yum history list (based on this available documentation).

Use Case

Customers may run the aforementioned history commands in their workflows and take specific actions based on if a non-zero exit status is returned or not. If they migrate to start using dnf instead of yum, these workflows may unexpectedly begin taking undesired actions.

For example, a customer may have a workflow that:

  • runs yum history package-list docker (if yum is being used) or dnf history list docker (if dnf is being used)
    • if a non-zero exit status is returned, install docker package
    • otherwise, proceed with an action that makes use of docker package

In the case where dnf is being used, the customer's workflow will proceed to perform an action that makes use of docker package even in the event that no transactions (including install) exist for the docker package. Such action is undesirable for the customer.

Ideally, dnf should match the yum behavior in this case so that customers can reliably detect errors in finding transactions for a given package when running these commands and act accordingly.

Current yum Behavior

Running yum history package-list docker and yum history list docker on an instance with docker not installed returns a non-zero exit status and an error message is written to stderr.

Click here to expand for full output of commands
$ sudo yum history package-list docker 2>&1 1>/dev/null ; echo $?
Bad transaction IDs, or package(s), given
Error: Failed history packages-list
1

$ sudo yum history package-list docker ; echo $?
Loaded plugins: priorities, update-motd
Bad transaction IDs, or package(s), given
Error: Failed history packages-list
1

$ sudo yum history list docker 2>&1 1>/dev/null ; echo $?
No transactions
Error: Failed history list
1

$ sudo yum history list docker ; echo $?
Loaded plugins: priorities, update-motd
No transactions
Error: Failed history list
1

Expected dnf Behavior

Running dnf history list docker and dnf history info docker on an instance with docker not installed returns a non-zero exit status and an error message is written to stderr. This aligns with the current yum behavior.

Observed dnf Behavior

Running dnf history list docker and dnf history info docker on an instance with docker not installed returns an exit status of 0 and no error message is written to stderr.

Click here to expand for full output of commands
$ sudo dnf history list docker 2>&1 1>/dev/null ; echo $?
0

$ sudo dnf history list  docker ; echo $?
No transaction which manipulates package 'docker' was found.
0

$ sudo dnf history info docker 2>&1 1>/dev/null ; echo $?
0

$ sudo dnf history info  docker ; echo $?
No transaction which manipulates package 'docker' was found.
0

Environment Details

Instance used to run yum commands is an Amazon Linux 2 x86_64 architecture instance with the below version of yum installed:

$ yum --version
3.4.3
  Installed: rpm-4.11.3-48.amzn2.0.4.x86_64 at 2025-02-01 06:59
  Built    : Amazon Linux at 2024-04-17 06:18
  Committed: Benjamin Herrenschmidt <[email protected]> at 2024-04-10

  Installed: yum-3.4.3-158.amzn2.0.7.noarch at 2025-02-01 06:59
  Built    : Amazon Linux at 2023-10-18 18:41
  Committed: Nic Anderson <[email protected]> at 2023-10-18

Instance used to run dnf commands is an Amazon Linux 2023 x86_64 architecture instance with the below version of dnf installed:

$ dnf --version
4.14.0
  Installed: dnf-0:4.14.0-1.amzn2023.0.5.noarch at Mon Feb  3 23:39:06 2025
  Built    : Amazon Linux at Thu Jun 20 16:37:29 2024
 
  Installed: rpm-0:4.16.1.3-29.amzn2023.0.6.x86_64 at Mon Feb  3 23:38:54 2025
  Built    : Amazon Linux at Mon Feb 26 20:41:20 2024
danehlim added a commit to danehlim/dnf that referenced this issue Feb 11, 2025
Require one transaction ID for history command actions "list" and "info"

= changelog =
msg: Require one transaction ID for history list + info
type: bugfix
resolves: rpm-software-management#2213
@danehlim danehlim linked a pull request Feb 11, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant