Bug 880019 - [ja_JP][SAM CLI] error: 'ascii' codec can't encode characters in position 0-4 for user create module with invalid boolean value to --disabled.
[ja_JP][SAM CLI] error: 'ascii' codec can't encode characters in position 0-4...
Status: CLOSED UPSTREAM
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Content Management (Show other bugs)
Nightly
x86_64 Linux
medium Severity medium (vote)
: Unspecified
: 6.0
Assigned To: Adam Price
SAM QE List
: i18n, Translation, Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-11-25 21:34 EST by Lijun Li
Modified: 2014-09-18 12:47 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-09-19 14:09:29 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Lijun Li 2012-11-25 21:34:16 EST
Description of problem:
error: 'ascii' codec can't encode characters in position 0-4 for user create module with invalid boolean value to --disabled.

Version-Release number of selected component (if applicable):
Subscription Asset Manager Version: 1.2.5-1h.el6_3

How reproducible:
100%

Steps to Reproduce:
[root@i18nsamtest ~]# locale
LANG=ja_JP.UTF-8
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_PAPER="ja_JP.UTF-8"
LC_NAME="ja_JP.UTF-8"
LC_ADDRESS="ja_JP.UTF-8"
LC_TELEPHONE="ja_JP.UTF-8"
LC_MEASUREMENT="ja_JP.UTF-8"
LC_IDENTIFICATION="ja_JP.UTF-8"
LC_ALL=
[root@i18nsamtest ~]# headpin -u admin -p admin user create --username=test --password=redhat --email=test@localhost --disabled=t --default_organization=test --default_environment=test --default_locale=en
error: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128) (more in the log file /var/log/katello/client.log)
^^^^^^^^^^Unexpect Error
[root@i18nsamtest ~]# LANG=en_US.UTF8 headpin -u admin -p admin user create --username=test --password=redhat --email=test@localhost --disabled=t --default_organization=test --default_environment=test --default_locale=en
Usage:  headpin <options> user create <options>

headpin: error: option --disabled: invalid boolean value: 't'
  
Actual results:
error: 'ascii' codec can't encode characters in position 0-4 for user create module with invalid boolean value to --disabled.

Expected results:
Should have no errors and should be the same as English:
headpin: error: option --disabled: invalid boolean value: 't

Additional info:
Comment 1 Adam Price 2012-12-05 16:33:23 EST
works for me in the latest puddle (2012.11.30)

[ root@mtndew ~ ]
==> export LANG=ja_JP.utf8
[ root@mtndew ~ ]
==> locale
LANG=ja_JP.utf8
LC_CTYPE="ja_JP.utf8"
LC_NUMERIC="ja_JP.utf8"
LC_TIME="ja_JP.utf8"
LC_COLLATE="ja_JP.utf8"
LC_MONETARY="ja_JP.utf8"
LC_MESSAGES="ja_JP.utf8"
LC_PAPER="ja_JP.utf8"
LC_NAME="ja_JP.utf8"
LC_ADDRESS="ja_JP.utf8"
LC_TELEPHONE="ja_JP.utf8"
LC_MEASUREMENT="ja_JP.utf8"
LC_IDENTIFICATION="ja_JP.utf8"
LC_ALL=
[ root@mtndew ~ ]
==> headpin -u admin -p admin user create --username="adam" --password="redhat" --email="adam@redhat.com" --disabled=true --default_organization="acme" --default_environment="dev" --default_locale="en"
ユーザー [ adam ] が正常に作成されました
("User [adam] has been successfully created")
Comment 2 Satyabrata Maitra 2012-12-06 01:49:59 EST
When I created the same like Adam did, it works for me as well :

[root@i18nsamtest ~]# headpin -u admin -p admin user create --username="smaitra" --password="redhat" --email="smaitra@redhat.com" --disabled=true --default_organization="test" --default_environment="test" --default_locale="en"
ユーザー [ smaitra ] が正常に作成されました

But the command used with parameters mentioned in this bug description, when executed, throws the same error mentioned in this bug :

[root@i18nsamtest ~]# headpin -u admin -p admin user create --username=test --password=redhat --email=test@localhost --disabled=t --default_organization=test --default_environment=test --default_locale=en
error: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128) (more in the log file /var/log/katello/client.log)

Actually I went to /var/log/katello/client.log to check, found some traceback pasted below :

2012-12-06 15:41:10,286 [ERROR][MainThread] error() @ base.py:189 - 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2012-12-06 15:41:10,287 [ERROR][MainThread] error() @ base.py:190 - Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/katello/client/cli/base.py", line 202, in main
    ret_code = super(KatelloCLI, self).main(args, command_name, parent_usage)
  File "/usr/lib/python2.6/site-packages/katello/client/core/base.py", line 314, in main
    return subcommand.main(self.args[1:], self.args[0], self._get_usage_line(command_name, parent_usage))
  File "/usr/lib/python2.6/site-packages/katello/client/core/base.py", line 314, in main
    return subcommand.main(self.args[1:], self.args[0], self._get_usage_line(command_name, parent_usage))
  File "/usr/lib/python2.6/site-packages/katello/client/core/base.py", line 391, in main
    self.setup_action(args, command_name, parent_usage)
  File "/usr/lib/python2.6/site-packages/katello/client/core/base.py", line 377, in setup_action
    self.process_options(parser, args)
  File "/usr/lib/python2.6/site-packages/katello/client/core/base.py", line 227, in process_options
    self.opts, self.args = parser.parse_args(args)
  File "/usr/lib64/python2.6/optparse.py", line 1396, in parse_args
    self.error(str(err))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)

What is your say Adam? May be it is something to do with the error handling? Or may be when the system fails to validate the username, email id, and suppose to throw or show error in local language, it is unable to bring the localized strings in display due to unicode error?  or something else?
Comment 3 Lijun Li 2012-12-10 02:17:02 EST
Please note '--disabled: invalid boolean value: 't'
Comment 4 Adam Price 2012-12-13 15:48:24 EST
ok, yes i can reproduce now. I initially read your bug report wrong.
Comment 5 Adam Price 2012-12-14 11:41:09 EST
it appears to be that this is a problem within Python's OptionParser. Optparse assumes that you will always be handing it ascii strings, but katello/headpin's exception handling contains localized messages, which is what causes optparse to throw UnicodeEncodeError.

working on a solution
Comment 6 Adam Price 2012-12-14 16:10:02 EST
this would require some very big changes to fix.
Comment 7 Tom McKay 2012-12-18 09:12:00 EST
Mass moving i18n BZs to CFSE where they are also present
Comment 9 Miroslav Suchý 2013-02-06 16:18:22 EST
https://github.com/Katello/katello/pull/1509
Comment 10 Og Maciel 2013-08-16 16:48:44 EDT
Satellite 6 MDP1
----------------

Still shows this same error:

# LANG=ja_JP katello -u $USERNAME -p $PASSWD user create --username=test --password=redhat --email=test@localhost --disabled=t --default_organization=test --default_environment=test --default_locale=en
Usage:  katello <options> user create <options>

katello: error: option --disabled: invalid boolean value: 't'

SAM 1.3 SNAP 2
--------------

Shows the error defined by https://bugzilla.redhat.com/show_bug.cgi?id=798323

# LANG=ja_JP headpin -u $USERNAME -p $PASSWD user create --username=test --password=redhat --email=test@localhost --disabled=t --default_organization=test --default_environment=test --default_locale=en
エラー: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128) (詳細はログファイル /var/log/katello/client.log を参照)
Comment 11 Mike McCune 2013-09-19 14:09:29 EDT
These bugs have been resolved in upstream projects for a period of months so I'm mass-closing them as CLOSED:UPSTREAM.  If this is a mistake feel free to re-open.

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