Bug 1607515 - Traceback UnicodeDecodeError in beaker-wizard when guessing Author
Summary: Traceback UnicodeDecodeError in beaker-wizard when guessing Author
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Beaker
Classification: Retired
Component: wizard
Version: 25
Hardware: Unspecified
OS: Linux
unspecified
low
Target Milestone: 25.6
Assignee: Dan Callaghan
QA Contact: Matt Tyson 🤬
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-07-23 15:52 UTC by Jiri Peska
Modified: 2018-09-03 23:31 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2018-09-03 23:31:40 UTC
Embargoed:


Attachments (Terms of Use)

Description Jiri Peska 2018-07-23 15:52:36 UTC
Description of problem:
Starting beaker-wizard client for the first time may lead to traceback if system user's name (GECOS) contains non-ascii letters. This happen only in interactive mode.

Version-Release number of selected component (if applicable):
beaker-client-25.4-1.fc28.noarch
beaker-client-25.5-1.el7bkr.noarch

How reproducible:
always
User name in passwd (GECOS field) contains non-ascii letters, e.g. 'čřžýáí'.
beaker-wizard is run interactively

Steps to Reproduce:
rm ~/.beaker_client/wizard
chfn -f 'čř'
beaker-wizard
accept everything (interactively)

Actual results:
Time for test to run
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The time must be in format [1-99][m|h|d] for 1-99 minutes/hours/days
(e.g. 3m, 2h, 1d)
[5m?] 

Author's name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Put your name [middle name] and surname here, abbreviations allowed.
Traceback (most recent call last):
  File "/usr/bin/beaker-wizard", line 11, in <module>
    load_entry_point('beaker-client==25.4', 'console_scripts', 'beaker-wizard')()
  File "/usr/lib/python2.7/site-packages/bkr/client/wizard.py", line 3065, in main
    test = Test(options)
  File "/usr/lib/python2.7/site-packages/bkr/client/wizard.py", line 1130, in __init__
    self.init()
  File "/usr/lib/python2.7/site-packages/bkr/client/wizard.py", line 2760, in init
    self.author = Author(self.options)
  File "/usr/lib/python2.7/site-packages/bkr/client/wizard.py", line 1135, in __init__
    self.ask()
  File "/usr/lib/python2.7/site-packages/bkr/client/wizard.py", line 1272, in ask
    sys.stdout.write("[%s] " % self.suggestion().encode("utf-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 2: ordinal not in range(128)

Expected results:
test is created from skeleton

Additional info:

Comment 1 Dan Callaghan 2018-07-26 05:22:55 UTC
Thanks for the detailed report Jiři.

I wonder if we should interpret GECOS as UTF-8 unconditionally, or according to the current locale... I am assuming, like all these UNIX APIs, it is historically defined as just bytes with encoding at the discretion of the sysadmin.

I see that Python 3 decodes the bytes from getpwuid() using PyUnicode_DecodeFSDefault(), which means it uses the "filesystem encoding" which has itself been fraught with problems...

https://docs.python.org/2/library/sys.html#sys.getfilesystemencoding

Not sure if that is better or worse than just hardcoding UTF-8. In all sane cases it will just be UTF-8 anyway.

I guess the best option while we are still on Python 2 is to explicitly decode using sys.getfilesystemencoding(), to match what the behaviour will be when we switch it to Python 3 eventually.

Comment 2 Dan Callaghan 2018-07-26 06:47:18 UTC
https://gerrit.beaker-project.org/#/c/beaker/+/6229

Comment 3 Dan Callaghan 2018-08-07 06:03:39 UTC
This bug fix is included in beaker-25.6-0.git.5.2f61d7f9f which is available for download here:

https://beaker-project.org/nightlies/release-25/

Comment 4 Matt Tyson 🤬 2018-08-23 03:32:21 UTC
Changed username using chfn, ran beaker wizard.  Confirmed that the old beaker-client crashes on the unicode username.

Installed the new beaker-client RPM and ran beaker-wizard again.  Beaker wizard succeeded with the new unicode username.

Comment 5 Roman Joost 2018-09-03 23:31:40 UTC
This has been released with Beaker 25.6.

Release Notes: https://beaker-project.org/docs/whats-new/release-25.html#beaker-25-6


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