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 1983144

Summary: request for more useful feedback when an unknown subscription-manager argument is typed
Product: Red Hat Enterprise Linux 9 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: mhorky
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: low Docs Contact:
Priority: medium    
Version: 9.0CC: mhorky, redakkan
Target Milestone: betaKeywords: Triaged
Target Release: 9.0Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: subscription-manager-1.29.21-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 15:58:13 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 2021-07-16 16:12:10 UTC
Description of problem:

After the recent move from optparse to argparse (https://github.com/candlepin/subscription-manager/commit/eef1bb13f8924af9539f98330465c110f2df92b5), the subscription-manager command line response when bad arguments are supplied has changed a little.  For example:

________________On RHEL-9:________________________________
[root@rhel9 ~]# subscription-manager attach --sku=RH00069
cannot parse argument: --sku=RH00069
[root@rhel9 ~]# echo $?
64
[root@rhel9 ~]# 

________________On RHEL-8:________________________________
[root@rhel8 ~]# subscription-manager attach --sku=RH00069
Usage: subscription-manager attach [OPTIONS]

subscription-manager: error: no such option: --sku
[root@rhel8 ~]# echo $?
2
[root@rhel8 ~]# 


Use this RFE to improve the response.  In my opinion, the rhel9 exit code of 64 (which represents EX_USAGE) is better, while the rhel8 stderr printing of a usage statement is a good clue to the user that they typed something wrong.  Maybe an automatic display of the --help output is better?  Maybe all the --help is too much?
Use this RFE to design a more friendly response that helps the user understand that the argument option that was typed is wrong and provides a little help.

Note that this applies to all of the subscription-manager modules.

Version-Release number of selected component (if applicable):
[root@rhel9 ~]# rpm -q subscription-manager
subscription-manager-1.29.17-1.el9.x86_64
[root@rhel8 ~]# rpm -q subscription-manager
subscription-manager-1.28.19-1.el8.x86_64

Comment 2 John Sefler 2021-07-16 18:15:33 UTC
Here is another difference in response when arguments are incomplete after the move from optparse to argparse...

________________On RHEL-9:________________________________
[root@rhel9 ~]# subscription-manager repo-override --repo
usage: subscription-manager repo-override [OPTIONS]
subscription-manager: error: argument --repo: expected one argument
[root@rhel9 ~]# echo $?
2
[root@rhel9 ~]# 


________________On RHEL-8:________________________________
[root@rhel8 ~]# subscription-manager repo-override --repo
Usage: subscription-manager repo-override [OPTIONS]

subscription-manager: error: --repo option requires 1 argument
[root@rhel8 ~]# echo $?
2
[root@rhel8 ~]# 


Note the capitalization difference in "usage"/"Usage" was reported in bug 1975641

Comment 4 John Sefler 2021-10-14 23:19:21 UTC
Preliminary testing...

[root@kvm-07-guest23 ~]# rpm -q subscription-manager
subscription-manager-1.29.19-1.git.57.bfd5f1c.el9.x86_64

[root@kvm-07-guest23 ~]# rpm -q subscription-manager --changelog | grep 1983144
- 1983144: More useful feedback on unknown argument (mhorky)

[root@kvm-07-guest23 ~]# subscription-manager attach --sku=RH00069
subscription-manager: error: no such option: --sku=RH00069
[root@kvm-07-guest23 ~]# echo $?
64
[root@kvm-07-guest23 ~]# 

VERIFIED: The stderr response of "subscription-manager: error: no such option: --sku=RH00069" closely matches the feedback originally reported on RHEL-8.
VERIFIED: The exitCode of 64 (EX_USAGE) is more accurate than 2.

The RHEL-9 response from comment 2 remains unchanged.

Comment 9 Rehana 2021-12-01 12:04:48 UTC
Verifying on : 
==========

# subscription-manager version
server type: This system is currently not registered.
subscription management server: 3.2.21-1
subscription management rules: 5.41
subscription-manager: 1.29.21-1.el9

# rpm -q subscription-manager --changelog | grep 1983144
- 1983144: More useful feedback on unknown argument (mhorky)

# subscription-manager attach --sku=RH00004
subscription-manager: error: no such option: --sku=RH00004

# echo $?
64

Both message and Exit codes issues have been resolved. Moving the bug to Verified!

Comment 11 errata-xmlrpc 2022-05-17 15:58:13 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 (new packages: subscription-manager), 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-2022:3984