Bug 836575 - 'ascii' codec error while assigning role to user
'ascii' codec error while assigning role to user
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Hammer (Show other bugs)
6.0.1
Unspecified Unspecified
unspecified Severity high (vote)
: Unspecified
: --
Assigned To: Ivan Necas
Hayk Hovsepyan
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-29 10:41 EDT by Hayk Hovsepyan
Modified: 2014-01-27 09:05 EST (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
The command line interface for assigning a role to a username that contained special characters resulted in an decoding error. This is due to improper handling of JSON data to the CLI. This fix corrects the CLI handling to include and decode JSON correctly. Special characters are now display correctly without error.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-12-04 14:47:04 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Hayk Hovsepyan 2012-06-29 10:41:22 EDT
Description of problem:
When we create a user by name which contains special characters, like "Mané" and try to assign some role to that user by CLI, it says "error: 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128) (more in the log file)".

Version-Release number of selected component (if applicable):
qpid-cpp-client-ssl-0.14-14.el6_2.x86_64
katello-selinux-0.1.10-1.el6.noarch
m2crypto-0.21.1.pulp-7.el6.x86_64
qpid-cpp-server-0.14-14.el6_2.x86_64
katello-glue-pulp-0.1.318-1.el6cf.noarch
katello-configure-0.1.110-1.el6_3.noarch
katello-qpid-client-key-pair-1.0-1.noarch
katello-cli-common-0.1.112-1.el6cf.noarch
katello-cli-0.1.112-1.el6cf.noarch
python-oauth2-1.5.170-2.pulp.el6.noarch
python-qpid-0.14-7.el6_2.noarch
python-isodate-0.4.4-4.pulp.el6.noarch
pulp-common-1.0.4-1.el6.noarch
candlepin-0.6.5-1.el6_2.noarch
qpid-cpp-client-0.14-14.el6_2.x86_64
pulp-1.0.4-1.el6.noarch
candlepin-tomcat6-0.6.5-1.el6_2.noarch
katello-glue-foreman-0.1.318-1.el6cf.noarch
katello-0.1.318-1.el6cf.noarch
katello-qpid-broker-key-pair-1.0-1.noarch
katello-agent-0.17-1.el6.noarch
grinder-0.0.143-1pulp_1.0.el6_3.noarch
katello-certs-tools-1.0.7-1.el6_3.noarch
qpid-cpp-server-ssl-0.14-14.el6_2.x86_64
pulp-selinux-server-1.0.4-1.el6.noarch
katello-common-0.1.318-1.el6cf.noarch
katello-glue-candlepin-0.1.318-1.el6cf.noarch
katello-candlepin-cert-key-pair-1.0-1.noarch
mod_wsgi-3.3-3.pulp.el6.x86_64


How reproducible:
only when you remotely execute CLI command in katello

Steps to Reproduce:
1. login to katello and create user from CLI like "user create --username "Mané" --password "testing" --email "root@localhost""
2. exit from katello and from server.
3. try to assign role Administrator to user just created "Mané" by executing 'ssh root@server  katello --username admin --password admin user assign_role --username Mané --role Administrator'. And you will see error "error: 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128) (more in the log file)"
  
Actual results:
Error is thrown, but role is added to user.

Expected results:
Role should be assigned to user without any error.

Additional info:
This is character encoding problem. When you try to execute the same while connected to katello by terminal like " katello --username admin --password admin user assign_role --username Mané --role Administrator" it works OK because terminal uses "LC_ALL=en_US.utf8" by default. But even you put LC_ALL=en_US.utf8 in remote command, it does not help.

Talked to inecas, he reproduced this problem and is working on this.
Comment 1 Ivan Necas 2012-07-04 14:36:15 EDT
After looking deeper into the code, here is the real cause of the issue:

Katello API is returning plain text informing about the status in plain text, but sending it with "Content-Type: application/json". For this reason katello client doesn't handle the response correctly (not converting it into unicode).

The CLI handling was fixed in the upstream, in commit  8503392419b57b38cfa5fbc6bfc17d6c490f4c6e. However the main cause (wrong content-type) is still there as well.

It affects only actions, that take plain response from the server and print it directly to the stdout.
Comment 2 Bryan Kearney 2012-08-27 10:26:52 EDT
I can not reproduce this error, but will add the code anbout returning json to the backlog.

[root@ktdev ~]# katello -u admin -p admin user create --username "Mané" --password "testing" --email "root@localhost"
Successfully created user [ Mané ]
[root@ktdev ~]# katello --username admin --password admin user assign_role --username Mané --role Administrator
User 'Mané' assigned to role 'Administrator'
[root@ktdev ~]# katello --username admin --password admin user unassign_role --username Mané --role Administrator
User 'Mané' unassigned from role 'Administrator'
Comment 10 Hayk Hovsepyan 2012-09-25 05:56:39 EDT
Verified on revision:
katello-certs-tools-1.1.8-1.el6cf.noarch
katello-glue-pulp-1.1.12-9.el6cf.noarch
katello-qpid-broker-key-pair-1.0-1.noarch
katello-agent-1.1.2-1.el6cf.noarch
katello-configure-1.1.9-4.el6cf.noarch
katello-glue-candlepin-1.1.12-9.el6cf.noarch
katello-candlepin-cert-key-pair-1.0-1.noarch
katello-selinux-1.1.1-1.el6cf.noarch
katello-common-1.1.12-9.el6cf.noarch
katello-1.1.12-9.el6cf.noarch
katello-qpid-client-key-pair-1.0-1.noarch
katello-cli-common-1.1.8-5.el6cf.noarch
katello-cli-1.1.8-5.el6cf.noarch
pulp-selinux-server-1.1.12-1.el6cf.noarch
katello-glue-pulp-1.1.12-9.el6cf.noarch
pulp-common-1.1.12-1.el6cf.noarch
python-isodate-0.4.4-4.pulp.el6.noarch
pulp-1.1.12-1.el6cf.noarch
m2crypto-0.21.1.pulp-7.el6.x86_64
python-oauth2-1.5.170-2.pulp.el6.noarch
mod_wsgi-3.3-3.pulp.el6.x86_64

Now it works correctly and does not show any error.
Tested by scenarios in description.
Comment 12 errata-xmlrpc 2012-12-04 14:47:04 EST
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, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-1543.html
Comment 13 Mike McCune 2013-08-16 14:15:57 EDT
getting rid of 6.0.0 version since that doesn't exist

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