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 1859157 - Change the dispalyed message when user tries to list available roles and usage for an invalid org
Summary: Change the dispalyed message when user tries to list available roles and usag...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: subscription-manager
Version: 8.3
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: 8.3
Assignee: mhorky
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On:
Blocks: 2022786
TreeView+ depends on / blocked
 
Reported: 2020-07-21 11:11 UTC by Shwetha Kallesh
Modified: 2022-05-10 16:39 UTC (History)
3 users (show)

Fixed In Version: subscription-manager-1.28.24-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2022786 (view as bug list)
Environment:
Last Closed: 2022-05-10 15:22:56 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github candlepin subscription-manager pull 2779 0 None Merged 1859157: Display better error message on incorrect --org 2021-09-15 09:27:23 UTC
Github candlepin subscription-manager pull 2781 0 None Merged [1.28] 1859157: Display better error message on incorrect --org 2021-09-15 09:27:24 UTC
Red Hat Product Errata RHBA-2022:2047 0 None None None 2022-05-10 15:23:20 UTC

Description Shwetha Kallesh 2020-07-21 11:11:13 UTC
Description of problem:
Change the dispalyed message when user tries to list available roles and usage for an invalid org

Version-Release number of selected component (if applicable):
[root@kvm-06-guest04 ~]# subscription-manager version
server type: This system is currently not registered.
subscription management server: 3.1.16-1
subscription management rules: 5.40
subscription-manager: 1.28.0-1.git.35.d436714.el8


How reproducible:


Steps to Reproduce:
[root@kvm-06-guest04 ~]# subscription-manager usage --list --username stage_auto_syspurpose001 --password redhat --org=adsad
Unable to get list of valid values for "usage"

[root@kvm-06-guest04 ~]# subscription-manager role --list --username stage_auto_syspurpose001 --password redhat --org=adsad
Unable to get list of valid values for "role"


Actual results:
Unable to get list of valid values for "role"

Expected results:
Organization with id adsad could not be found.


Additional info:
Service-level displays proper info/message

[root@kvm-06-guest04 ~]# subscription-manager service-level --list --username stage_auto_syspurpose001 --password redhat
Organization: dsfds
Organization with id dsfds could not be found.

Comment 1 Shwetha Kallesh 2020-07-21 11:21:47 UTC
Also exit code is 0 , even though it was an unsuccessful execution

[root@kvm-06-guest04 ~]# echo $?
0

Comment 2 Shwetha Kallesh 2020-07-22 13:31:58 UTC
[root@kvm-07-guest02 ~]# subscription-manager role --list --username stage_auto_testuserdsadsa --password redhats
Organization: 12814047
Unable to get list of valid values for "role"
^^ can we be more specific about the reason for not listing roles like "Invalid User credentials"

[root@kvm-07-guest02 ~]# echo $?
0
^^ Also exit code is zero on a unsuccessful transaction here

Comment 4 John Sefler 2021-08-04 21:02:58 UTC
Update: The actual response has changed a little due to bug 1973731...

[root@kvm-07-guest20 ~]# rpm -q subscription-manager
subscription-manager-1.28.19-1.el8.x86_64
[root@kvm-07-guest20 ~]# rpm -q subscription-manager --changelog | grep 1973731
- 1973731: fix wording on error when listing syspurpose values

[root@kvm-07-guest20 ~]# subscription-manager usage --list --username stage_auto_syspurpose001 --password redhat --org=adsad
Unable to get the list of valid values for the system purpose "usage".
[root@kvm-07-guest20 ~]# echo $?
0

[root@kvm-07-guest20 ~]# subscription-manager role --list --username stage_auto_syspurpose001 --password redhat --org=adsad
Unable to get the list of valid values for the system purpose "role".
[root@kvm-07-guest20 ~]# echo $?
0

[root@kvm-07-guest20 ~]# subscription-manager addons --list --username stage_auto_syspurpose001 --password redhat --org=adsad
Unable to get the list of valid values for the system purpose "addons".
[root@kvm-07-guest20 ~]# echo $?
0

Also be aware that the argument for an org is not even processed when the username/password does not exist for any org.  In the cases above, we are unable to retrieve values because the username/password are invalid and the org value is irrelevant.  When a valid username/password that belongs to one org is supplied, then we get results regardless of an org option (because the org is not needed) as shown here ....

[root@kvm-07-guest20 ~]# subscription-manager usage --list --username stage_rhsmqe_syspurposeuser01 --password REDACTED
+-------------------------------------------+
               Available usage
+-------------------------------------------+
 - Development/Test
 - Production
 - Disaster Recovery

[root@kvm-07-guest20 ~]# subscription-manager usage --list --username stage_rhsmqe_syspurposeuser01 --password REDACTED --org adsad
+-------------------------------------------+
               Available usage
+-------------------------------------------+
 - Development/Test
 - Production
 - Disaster Recovery

Comment 6 Pino Toscano 2021-11-22 13:42:12 UTC
After the latest changes related to syspurpose commands (i.e. https://github.com/candlepin/subscription-manager/pull/2781 ), there were the following changes:

(In reply to Shwetha Kallesh from comment #0)
> [root@kvm-06-guest04 ~]# subscription-manager usage --list --username stage_auto_syspurpose001 --password redhat --org=adsad
> Unable to get list of valid values for "usage"

This failed already when querying the server for the list of available values; rather than saying only that, now there is the actual error message (usually from candlepin), formatted in the same way as in other flows/commands. For example, for an invalid username and/or password, there will be an error message mentioning invalid credentials.

(In reply to Shwetha Kallesh from comment #1)
> Also exit code is 0 , even though it was an unsuccessful execution
> 
> [root@kvm-06-guest04 ~]# echo $?
> 0

This is fixed too: since the situation is an error, there will be a non-zero exit code.

Comment 12 Rehana 2021-11-29 12:38:06 UTC
Verifying the fix 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.28.24-1.el8

# rpm -qa --changelog subscription-manager | grep 1859157
- [1.28] 1859157: Display better error message on incorrect --org

1. When user belong to multiple org with valid credentials and invalid org is given
===================================================================================
Demonstrating with test data 

User "testuser1" belongs to two org as shown below

# subscription-manager orgs
Username: testuser1
Password: 
+-------------------------------------------+
          testuser1 Organizations
+-------------------------------------------+

Name: Admin Owner
Key:  admin

Name: Snow White
Key:  snowwhite


# subscription-manager usage --list --username testuser1 --password=**** --org=donaldduck
Organization with id donaldduck could not be found. (HTTP error code 404: Not Found)
# echo $?
70

# subscription-manager role --list --username testuser1 --password=***** --org=donaldduck
Organization with id donaldduck could not be found. (HTTP error code 404: Not Found)
# echo $?
70

# subscription-manager addons --list --username testuser1 --password=***** --org=donaldduck
Organization with id donaldduck could not be found. (HTTP error code 404: Not Found)
# echo $?
70

# subscription-manager service-level --list --username testuser1 --password=***** --org=donaldduck
Organization with id donaldduck could not be found. (HTTP error code 404: Not Found)
# echo $?
65

Notice the error message and exit codes have been fixed


2 When user belong to multiple org with invalid credentials and invalid org is given
===================================================================================
# subscription-manager role --list --username testuser1 --password=password111 --org=donaldduck
Invalid Credentials (HTTP error code 401: Unauthorized)
# echo $?
70

# subscription-manager usage --list --username testuser1 --password=password111 --org=donaldduck
Invalid Credentials (HTTP error code 401: Unauthorized)
# echo $?
70

# subscription-manager addons --list --username testuser1 --password=password111 --org=donaldduck
Invalid Credentials (HTTP error code 401: Unauthorized)
# echo $?
70

# subscription-manager service-level --list --username testuser1 --password=password111 --org=donaldduck
Invalid Credentials (HTTP error code 401: Unauthorized)
# echo $?
70

Notice the error message and exit codes have been fixed

3. When the user belong to single org ; valid credentials with invalid org 
=======================================================
# subscription-manager role --list --username=rhsm_nonsca_1 --password=***** --org=foo
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - Red Hat Enterprise Linux Server

# subscription-manager usage --list --username=rhsm_nonsca_1 --password=***** --org=foo
+-------------------------------------------+
               Available usage
+-------------------------------------------+
 - Production

# echo $?
0

# subscription-manager role --list --username=rhsm_nonsca_1 --password=***** --org=foo
+-------------------------------------------+
               Available role
+-------------------------------------------+
 - Red Hat Enterprise Linux Server

# echo $?
0

# subscription-manager service-level --list --username=rhsm_nonsca_1 --password=****** --org=foo
Organization with id foo could not be found. (HTTP error code 404: Not Found)

# echo $?
65

# subscription-manager addons --list --username=rhsm_nonsca_1 --password=**** --org=foo
There are no available values for the system purpose "addons" from the available subscriptions in this organization.

# echo $?
0

To make the behaviour a new bug has been reported Bug 2026013

4. When the user belong to single org ; invalid credentials with invalid org 
=======================================================

# subscription-manager usage --list --username stage_auto_syspurpose --password redhat --org=adsad
Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html (HTTP error code 401: Unauthorized)
# echo $?
70

# subscription-manager role --list --username stage_auto_syspurpose --password redhat --org=adsad
Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html (HTTP error code 401: Unauthorized)
# echo $?
70

# subscription-manager service-level --list --username stage_auto_syspurpose --password redhat --org=adsad
Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html (HTTP error code 401: Unauthorized)
# echo $?
70

# subscription-manager addons --list --username stage_auto_syspurpose --password redhat --org=adsad
Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html (HTTP error code 401: Unauthorized)
# echo $?
70

Notice the error message and exit codes have been fixed; Based on the above observation moving the bug to verified!!

Comment 14 errata-xmlrpc 2022-05-10 15:22:56 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-2022:2047


Note You need to log in before you can comment on or make changes to this bug.