Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2189625

Summary: Traceback for InvalidCLIOptionError is thrown by rhsm-debug system with negative option values
Product: Red Hat Enterprise Linux 9 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: Pino Toscano <ptoscano>
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.3Keywords: AutoVerified, Regression, Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 9.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: subscription-manager-1.29.35-1.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-07 08:51:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description John Sefler 2023-04-25 17:50:17 UTC
Description of problem:
This is a negative test that is now throwing Traceback subscription_manager.cli.InvalidCLIOptionError that was previously caught gracefully on RHEL-9.2.


Version-Release number of selected component (if applicable):
[root@kvm-02-guest13 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 4.2.15-1
subscription management rules: 5.43
subscription-manager: 1.29.34-1.el9


How reproducible:


Steps to Reproduce:
[root@kvm-02-guest13 ~]# subscription-manager register --serverurl=subscription.rhsm.stage.redhat.com
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: stage_rhsmqe_testuser01
Password: 
The system has been registered with ID: 579dcdbf-f56c-4472-8eb9-e2c521b448ff
The registered system name is: kvm-02-guest13.lab.eng.rdu2.redhat.com
[root@kvm-02-guest13 ~]# rhsm-debug system --destination=/tmp/rhsmDebugNonExistantDestination/
Traceback (most recent call last):
  File "/usr/bin/rhsm-debug", line 33, in <module>
    sys.exit(load_entry_point('subscription-manager==1.29.34', 'console_scripts', 'rhsm-debug')())
  File "/usr/lib64/python3.9/site-packages/subscription_manager/scripts/rhsm_debug.py", line 46, in main
    return RhsmDebugCLI().main()
  File "/usr/lib64/python3.9/site-packages/subscription_manager/cli.py", line 197, in main
    return cmd.main()
  File "/usr/lib64/python3.9/site-packages/subscription_manager/cli_command/cli.py", line 443, in main
    raise err
  File "/usr/lib64/python3.9/site-packages/subscription_manager/cli_command/cli.py", line 412, in main
    return_code = self._do_command()
  File "/usr/lib64/python3.9/site-packages/rhsm_debug/debug_commands.py", line 129, in _do_command
    self._validate_options()
  File "/usr/lib64/python3.9/site-packages/rhsm_debug/debug_commands.py", line 110, in _validate_options
    raise InvalidCLIOptionError(_("The directory specified by '--destination' must already exist."))
subscription_manager.cli.InvalidCLIOptionError: The directory specified by '--destination' must already exist.


Actual results:
Traceback as shown above

Expected results:
Same as RHEL-9.2...
[root@kvm-03-guest21 ~]# rpm -q subscription-manager
subscription-manager-1.29.33.1-1.el9_2.x86_64
[root@kvm-03-guest21 ~]# rhsm-debug system --destination=/tmp/rhsmDebugNonExistantDestination/
The directory specified by '--destination' must already exist.
[root@kvm-03-guest21 ~]# echo $?
0

Additional info:

Comment 1 John Sefler 2023-04-25 17:53:21 UTC
The same issue happens with...

[root@kvm-02-guest13 ~]# rhsm-debug system --destination=/dev/null --no-archive
Traceback (most recent call last):
  File "/usr/bin/rhsm-debug", line 33, in <module>
    sys.exit(load_entry_point('subscription-manager==1.29.34', 'console_scripts', 'rhsm-debug')())
  File "/usr/lib64/python3.9/site-packages/subscription_manager/scripts/rhsm_debug.py", line 46, in main
    return RhsmDebugCLI().main()
  File "/usr/lib64/python3.9/site-packages/subscription_manager/cli.py", line 197, in main
    return cmd.main()
  File "/usr/lib64/python3.9/site-packages/subscription_manager/cli_command/cli.py", line 443, in main
    raise err
  File "/usr/lib64/python3.9/site-packages/subscription_manager/cli_command/cli.py", line 412, in main
    return_code = self._do_command()
  File "/usr/lib64/python3.9/site-packages/rhsm_debug/debug_commands.py", line 129, in _do_command
    self._validate_options()
  File "/usr/lib64/python3.9/site-packages/rhsm_debug/debug_commands.py", line 119, in _validate_options
    raise InvalidCLIOptionError(msg)
subscription_manager.cli.InvalidCLIOptionError: To use the no-archive option, the destination directory '/dev/null' must exist on the same file system as the data assembly directory '/var/spool/rhsm/debug'.


Expected results:
Same as RHEL-9.2...
[root@kvm-03-guest21 ~]# rhsm-debug system --destination=/dev/null --no-archive
To use the no-archive option, the destination directory '/dev/null' must exist on the same file system as the data assembly directory '/var/spool/rhsm/debug'.
[root@kvm-03-guest21 ~]# echo $?
0

Comment 2 Pino Toscano 2023-04-27 03:38:36 UTC
Thanks for the report; this is a regression in the handling of invalid command line options in tools different than 'subscription-manager'.
Sent a PR to hopefully fix it:
https://github.com/candlepin/subscription-manager/pull/3251

Note: as result of this, the return value of 'rhsm-debug' for invalid command line options will change from 0 to 1: while this can be seen as behaviour change, I'd argue that errors ought to not cause a clean exit.

Comment 11 errata-xmlrpc 2023-11-07 08:51:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (subscription-manager bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:6606