Bug 1766445

Summary: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 55: ordinal not in range(128)
Product: Red Hat Enterprise Linux 7 Reporter: Douglas Schilling Landgraf <dougsland>
Component: subscription-managerAssignee: Jiri Hnidek <jhnidek>
Status: CLOSED NOTABUG QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.7CC: csnyder, jhnidek, wpoteat
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-01-22 18:54:29 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:
Bug Depends On:    
Bug Blocks: 1752522    

Description Douglas Schilling Landgraf 2019-10-29 04:50:22 UTC
Description of problem:

If users with non US unicode try to enable a repository that is already enabled subscription-manager will raise an Unicode error.

Version-Release number of selected component (if applicable):

RHEL 7 family:

# rpm -qa | grep subscription-manager
subscription-manager-rhsm-1.24.23-1.el7.x86_64
subscription-manager-rhsm-certificates-1.24.23-1.el7.x86_64
subscription-manager-1.24.23-1.el7.x86_64

or 

subscription-manager-rhsm-1.24.13-3.el7_7.x86_64
subscription-manager-rhsm-certificates-1.24.13-3.el7_7.x86_64
subscription-manager-1.24.13-3.el7_7.x86_64


How reproducible:
1. Edit the locale, example:
# cat /etc/locale.conf 
LANG=fr_FR.UTF-8
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=

2. Reboot

3. Try to enable a repo which is already enabled
# env LC_ALL=C subscription-manager repos --enable rhel-7-server-rhv-4.3-manager-rpms --enable jb-eap-7.2-for-rhel-7-server-rpms
Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 9, in <module>
    load_entry_point('subscription-manager==1.24.13', 'console_scripts', 'subscription-manager')()
  File "/usr/lib64/python2.7/site-packages/subscription_manager/scripts/subscription_manager.py", line 85, in main
    return managercli.ManagerCLI().main()
  File "/usr/lib64/python2.7/site-packages/subscription_manager/managercli.py", line 2922, in main
    ret = CLI.main(self)
  File "/usr/lib64/python2.7/site-packages/subscription_manager/cli.py", line 183, in main
    return cmd.main()
  File "/usr/lib64/python2.7/site-packages/subscription_manager/managercli.py", line 506, in main
    return_code = self._do_command()
  File "/usr/lib64/python2.7/site-packages/subscription_manager/managercli.py", line 2260, in _do_command
    rc = self._set_repo_status(repos, rl, self.options.repo_actions)
  File "/usr/lib64/python2.7/site-packages/subscription_manager/managercli.py", line 2358, in _set_repo_status
    print(_("Repository '%s' is enabled for this system.") % repo.id)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 4: ordinal not in range(128)

Actual results:
raised Unicode error

Expected results:
Just print a error message to users (not UnicodeEncodeError raise)

Comment 2 Douglas Schilling Landgraf 2019-10-29 04:55:58 UTC
Proposal patch: https://github.com/candlepin/subscription-manager/pull/2179

Comment 3 Douglas Schilling Landgraf 2020-01-22 18:54:29 UTC
Using env -i LC_ALL=C  solves the issue. Thanks!