"openstack user show" command fails if user has non-Latin name or description

Bug #1933513 reported by Vladimir Grevtsev
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Clients Snap
Fix Released
Undecided
Billy Olsen

Bug Description

$ snap list | grep clients
openstackclients ussuri 116 ussuri/stable canonical*

openstack user show abaev --domain 40ea7f882ee24533ab357a4e7199698c -c description --debug

http://keystone.openstack.test:5000 "GET /v3/users?domain_id=40ea7f882ee24533ab357a4e7199698c&name=abaev HTTP/1.1" 200 632
RESP: [200] Connection: Keep-Alive Content-Length: 632 Content-Type: application/json Date: Thu, 24 Jun 2021 15:01:07 GMT Keep-Alive: timeout=5, max=94 Server: Apache/2.4.41 (Ubuntu) Vary: X-Auth-Token x-openstack-request-id: req-ca42dbc1-0ac1-45cb-8ba0-51ca32ddabac
RESP BODY: {"users": [{"id": "bede3ae90cf87e878242a4185bfc68b91a1aa05fa784cd1ae0780782b07fbdf1", "name": "abaev", "description": "\u0422\u0435\u0441\u0442\u043e\u0432 \u0422\u0435\u0441\u0442 \u0422\u0435\u0441\u0442\u043e\u0432\u0438\u0447", "options": {}, "password_expires_at": null, "domain_id": "40ea7f882ee24533ab357a4e7199698c", "links": {"self": "http://keystone.openstack.test:5000/v3/users/bede3ae90cf87e878242a4185bfc68b91a1aa05fa784cd1ae0780782b07fbdf1"}}], "links": {"next": null, "self": "http://keystone.openstack.test:5000/v3/users?domain_id=40ea7f882ee24533ab357a4e7199698c&name=abaev", "previous": null}}

GET call to identity for http://keystone.openstack.test:5000/v3/users?domain_id=40ea7f882ee24533ab357a4e7199698c&name=abaev used request id req-ca42dbc1-0ac1-45cb-8ba0-51ca32ddabac
'ascii' codec can't encode characters in position 133-138: ordinal not in range(128)
Traceback (most recent call last):
  File "/snap/openstackclients/116/lib/python3.6/site-packages/cliff/app.py", line 400, in run_subcommand
    result = cmd.run(parsed_args)
  File "/snap/openstackclients/116/lib/python3.6/site-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/snap/openstackclients/116/lib/python3.6/site-packages/cliff/display.py", line 120, in run
    self.produce_output(parsed_args, column_names, data)
  File "/snap/openstackclients/116/lib/python3.6/site-packages/cliff/show.py", line 49, in produce_output
    parsed_args)
  File "/snap/openstackclients/116/lib/python3.6/site-packages/cliff/formatters/table.py", line 137, in emit_one
    stdout.write(formatted)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 133-138: ordinal not in range(128)
clean_up ShowUser: 'ascii' codec can't encode characters in position 133-138: ordinal not in range(128)
END return value: 1

The same, but avoiding "description" field works fine:

$ os user show abaev --domain 40ea7f882ee24533ab357a4e7199698c -c id -f value
bede3ae90cf87e878242a4185bfc68b91a1aa05fa784cd1ae0780782b07fbdf1

Revision history for this message
Vladimir Grevtsev (vlgrevtsev) wrote :

adding field-high, as this is affecting ongoing customer delivery.

Revision history for this message
Vladimir Grevtsev (vlgrevtsev) wrote :

Same behaviour is observed inside the snap env:

$ snap run --shell openstackclients.openstack
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
$ env | grep LANG
LANG=en_US.UTF-8
$ openstack user show abaev --domain 40ea7f882ee24533ab357a4e7199698c
'ascii' codec can't encode characters in position 297-302: ordinal not in range(128)

Revision history for this message
Drew Freiberger (afreiberger) wrote :

The upstream project seems to leave this to the operator of the given client to solve:
https://docs.openstack.org/python-openstackclient/ocata/configuration.html#redirecting-output

The workaround is simple:

export PYTHONIOENCODING=utf-8

It's documented that this can be updated in the python installation's site.py.

It would be excellent if we solve for this within the snapcraft.yaml for a better all around user experience.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to snap-openstackclients (master)
Changed in snap-openstackclients:
status: New → In Progress
Changed in snap-openstackclients:
assignee: nobody → Billy Olsen (billy-olsen)
James Page (james-page)
Changed in snap-openstackclients:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to snap-openstackclients (master)

Reviewed: https://review.opendev.org/c/x/snap-openstackclients/+/804808
Committed: https://opendev.org/x/snap-openstackclients/commit/339687fe610426ec236907e9e6c09d49cecf03fc
Submitter: "Zuul (22348)"
Branch: master

commit 339687fe610426ec236907e9e6c09d49cecf03fc
Author: Billy Olsen <email address hidden>
Date: Mon Aug 16 16:56:30 2021 -0700

    Set PYTHONIOENCODING to utf-8

    Set the PYTHONIOENCODING to utf-8 in order to prevent the python
    interpreter from treating the character sets as ASCII.

    Closes-Bug: #1933513
    Change-Id: Iec5af33bded88cabd16933ce2c7ff63635a945cc

Changed in snap-openstackclients:
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to snap-openstackclients (stable/xena)

Fix proposed to branch: stable/xena
Review: https://review.opendev.org/c/x/snap-openstackclients/+/829417

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to snap-openstackclients (stable/wallaby)

Fix proposed to branch: stable/wallaby
Review: https://review.opendev.org/c/x/snap-openstackclients/+/829422

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to snap-openstackclients (stable/victoria)

Fix proposed to branch: stable/victoria
Review: https://review.opendev.org/c/x/snap-openstackclients/+/829424

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to snap-openstackclients (stable/ussuri)

Fix proposed to branch: stable/ussuri
Review: https://review.opendev.org/c/x/snap-openstackclients/+/829425

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to snap-openstackclients (stable/xena)

Reviewed: https://review.opendev.org/c/x/snap-openstackclients/+/829417
Committed: https://opendev.org/x/snap-openstackclients/commit/bee63f70a20a138b1bec60033bfa095633e19163
Submitter: "Zuul (22348)"
Branch: stable/xena

commit bee63f70a20a138b1bec60033bfa095633e19163
Author: Billy Olsen <email address hidden>
Date: Mon Aug 16 16:56:30 2021 -0700

    Set PYTHONIOENCODING to utf-8

    Set the PYTHONIOENCODING to utf-8 in order to prevent the python
    interpreter from treating the character sets as ASCII.

    Closes-Bug: #1933513
    Change-Id: Iec5af33bded88cabd16933ce2c7ff63635a945cc
    (cherry picked from commit 339687fe610426ec236907e9e6c09d49cecf03fc)

tags: added: in-stable-xena
tags: added: in-stable-victoria
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to snap-openstackclients (stable/victoria)

Reviewed: https://review.opendev.org/c/x/snap-openstackclients/+/829424
Committed: https://opendev.org/x/snap-openstackclients/commit/d0ca4702edaaa8c00d927b52225ff9ca3572c159
Submitter: "Zuul (22348)"
Branch: stable/victoria

commit d0ca4702edaaa8c00d927b52225ff9ca3572c159
Author: Billy Olsen <email address hidden>
Date: Mon Aug 16 16:56:30 2021 -0700

    Set PYTHONIOENCODING to utf-8

    Set the PYTHONIOENCODING to utf-8 in order to prevent the python
    interpreter from treating the character sets as ASCII.

    Closes-Bug: #1933513
    Change-Id: Iec5af33bded88cabd16933ce2c7ff63635a945cc
    (cherry picked from commit 339687fe610426ec236907e9e6c09d49cecf03fc)

tags: added: in-stable-ussuri
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to snap-openstackclients (stable/ussuri)

Reviewed: https://review.opendev.org/c/x/snap-openstackclients/+/829425
Committed: https://opendev.org/x/snap-openstackclients/commit/fadc7c2947e8337bf4dc23c8f1f1f9d4d1baab7c
Submitter: "Zuul (22348)"
Branch: stable/ussuri

commit fadc7c2947e8337bf4dc23c8f1f1f9d4d1baab7c
Author: Billy Olsen <email address hidden>
Date: Mon Aug 16 16:56:30 2021 -0700

    Set PYTHONIOENCODING to utf-8

    Set the PYTHONIOENCODING to utf-8 in order to prevent the python
    interpreter from treating the character sets as ASCII.

    Closes-Bug: #1933513
    Change-Id: Iec5af33bded88cabd16933ce2c7ff63635a945cc
    (cherry picked from commit 339687fe610426ec236907e9e6c09d49cecf03fc)

tags: added: in-stable-wallaby
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to snap-openstackclients (stable/wallaby)

Reviewed: https://review.opendev.org/c/x/snap-openstackclients/+/829422
Committed: https://opendev.org/x/snap-openstackclients/commit/6290d81743f8bcce495ae04334d1f0f4d53b3ca5
Submitter: "Zuul (22348)"
Branch: stable/wallaby

commit 6290d81743f8bcce495ae04334d1f0f4d53b3ca5
Author: Billy Olsen <email address hidden>
Date: Mon Aug 16 16:56:30 2021 -0700

    Set PYTHONIOENCODING to utf-8

    Set the PYTHONIOENCODING to utf-8 in order to prevent the python
    interpreter from treating the character sets as ASCII.

    Closes-Bug: #1933513
    Change-Id: Iec5af33bded88cabd16933ce2c7ff63635a945cc
    (cherry picked from commit 339687fe610426ec236907e9e6c09d49cecf03fc)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.