Bug 1976240

Summary: [RFE] improve HTTP code/message reporting in error strings
Product: Red Hat Enterprise Linux 9 Reporter: Pino Toscano <ptoscano>
Component: subscription-managerAssignee: mhorky
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.0CC: jsefler, mhorky, redakkan, zpetrace
Target Milestone: betaKeywords: FutureFeature, Triaged
Target Release: 9.0 Beta   
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 Pino Toscano 2021-06-25 15:27:57 UTC
Description of problem:
As described in bug 1961390: in recent versions of subscription-manager, the HTTP error code & message is prefixed to the string printed to the user in case of errors, e.g.:

  # subscription-manager attach --quantity=2 --pool=8a99f9ac75743133017575f553fc0093 --pool=8a99f9ac75743133017575f5541c0095
  HTTP error (403 - Forbidden): Multi-entitlement not supported for pool with ID "8a99f9ac75743133017575f553fc0093".

During triaging, we decided that printing the HTTP code & message is something that was actually supposed to happen for a very long time, and apparently "it didn't happen". The only issue is that the HTTP bits are printed before the actual error message, and thus may give an unfriendly look at the message, possibly even making it more scary than it actually is.

The proposal is thus to rework the error message printed to the user, moving the HTTP bits at the end of the message; a potential example for the above output is:

  # subscription-manager attach --quantity=2 --pool=8a99f9ac75743133017575f553fc0093 --pool=8a99f9ac75743133017575f5541c0095
  Multi-entitlement not supported for pool with ID "8a99f9ac75743133017575f553fc0093" (HTTP error 403, Forbidden).

Comment 2 John Sefler 2021-06-25 15:49:06 UTC
I like the proposal with a small change to the format.  Let's complete the message with a period before appending the suffix as shown in this example, and let's make use of the already existing translations for string src/subscription_manager/exceptions.py:RESTLIB_MESSAGE = _(u"HTTP error code %s: %s")

  # subscription-manager attach --quantity=2 --pool=8a99f9ac75743133017575f553fc0093
  Multi-entitlement not supported for pool with ID "8a99f9ac75743133017575f553fc0093". (HTTP error code 403: Forbidden)

Comment 3 Zdenek Petracek 2021-11-11 12:50:52 UTC
[root@kvm-08-guest11 ~]# rpm -q subscription-manager --changelog | grep 1976240
- 1976240: Improve HTTP code/message reporting in error strings
[root@kvm-08-guest11 ~]# subscription-manager version

Version:
server type: Red Hat Subscription Management
subscription management server: 3.2.21-1
subscription management rules: 5.41
subscription-manager: 1.29.19-1.git.119.033bf98.el9

Registering:
[root@kvm-08-guest11 ~]# subscription-manager register
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: zpetracePH03
Password: 
The system has been registered with ID: dec1b13c-eacf-4f6e-8878-f3f2819dc2f8
The registered system name is: kvm-08-guest11.hv2.lab.eng.bos.redhat.com

Available pools:
[root@kvm-08-guest11 ~]# subscription-manager list --avail --pool-only
8a99f9ac7b5ee892017bc59cbab16930
8a99f9ac7b5ee892017bc59f5c236932
8a99f9ad7bca8239017bdf952e2e051d
8a99f9ad7bca8239017bdf952e77051f
8a99f9ad7bca8239017bdf954e010521

Pre-verification 1:
[root@kvm-08-guest11 ~]# subscription-manager attach --quantity=2 --pool=8a99f9ac7b5ee892017bc59cbab16930 --pool=8a99f9ac7b5ee892017bc59f5c236932
Multi-entitlement not supported for pool with ID "8a99f9ac7b5ee892017bc59f5c236932". (HTTP error code 403: Forbidden)
^^ message fits the suggested comment --> PASSED

Pre-verification 2:
[root@kvm-08-guest11 ~]# subscription-manager attach --quantity=3 --pool=8a99f9ac7b5ee892017bc59f5c236932
Multi-entitlement not supported for pool with ID "8a99f9ac7b5ee892017bc59f5c236932". (HTTP error code 403: Forbidden)
^^ message fits the suggested comment --> PASSED

Comment 7 Rehana 2021-12-01 12:15:14 UTC
Verifying on :
=============

# rpm -q subscription-manager --changelog | grep 1976240
- 1976240: Improve HTTP code/message reporting in error strings

# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.21-1
subscription management rules: 5.41
subscription-manager: 1.29.21-1.el9

# subscription-manager list --avail --pool-only
8a99f9ac7d4946d5017d567aee5c0437
8a99f9ac7d4946d5017d56fb218e0480
8a99f9af7d4d1194017d5676eeba04cf

# subscription-manager attach --pool 8a99f9ac7d4946d5017d567aee5c0437 --quantity=2
Multi-entitlement not supported for pool with ID "8a99f9ac7d4946d5017d567aee5c0437". (HTTP error code 403: Forbidden)

^^ notice the error codes were move to the end of message . Verifying the bug

Comment 9 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