Bug 1014623 - poor handling of utf-8 strings in bkr client
poor handling of utf-8 strings in bkr client
Status: CLOSED CURRENTRELEASE
Product: Beaker
Classification: Community
Component: command line (Show other bugs)
0.14
Unspecified Unspecified
unspecified Severity unspecified (vote)
: 0.14.2
: ---
Assigned To: Dan Callaghan
tools-bugs
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-02 08:29 EDT by Martin Kyral
Modified: 2018-02-05 19:41 EST (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-11-06 20:47:24 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)
encode myxml to utf-8 upon creation (536 bytes, patch)
2013-10-02 08:29 EDT, Martin Kyral
no flags Details | Diff

  None (edit)
Description Martin Kyral 2013-10-02 08:29:57 EDT
Created attachment 806402 [details]
encode myxml to utf-8 upon creation

Description of problem:

$ bkr job-results --prettyxml J:507498
Traceback (most recent call last):
  File "/usr/bin/bkr", line 9, in <module>
      load_entry_point('bkr.client==0.14.1', 'console_scripts', 'bkr')()
    File "/usr/lib/python2.7/site-packages/bkr/client/main.py", line 50, in main
      return cmd.run(*cmd_args, **cmd_opts.__dict__)
    File "/usr/lib/python2.7/site-packages/bkr/client/commands/cmd_job_results.py", line 83, in run
      print parseString(myxml).toprettyxml()
    File "/usr/lib64/python2.7/xml/dom/minidom.py", line 1931, in parseString
      return expatbuilder.parseString(string)
    File "/usr/lib64/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
      return builder.parseString(string)
    File "/usr/lib64/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
      parser.Parse(string, True)
  UnicodeEncodeError: 'ascii' codec can't encode characters in position 150082-150084: ordinal not in range(128)
$

Version-Release number of selected component (if applicable):
beaker-client-0.14.1-1.fc18.noarch

How reproducible:
always

Steps to Reproduce:
1. see description

Actual results:
'ascii' codec failure


Expected results:
XML containing the job's results is generated


Additional info:
attaching proposed patch
Comment 2 Nick Coghlan 2013-10-02 22:02:49 EDT
The underlying problem here is that we're sending an XML document through XML-RPC as a unicode string rather than as a binary sequence. However, we can't change that without breaking the server API, so this is a good suggested fix.

We can get away with hardcoding UTF-8 (rather than checking for an encoding declaration in the XML) because we control the server side as well and always use UTF-8 as the encoding declaration in our XML data.
Comment 5 Dan Callaghan 2013-10-14 20:41:02 EDT
Thanks for the patch, Martin!

bkr job-clone suffers the same problem, this patch fixes them both:

http://gerrit.beaker-project.org/2359
Comment 8 Raymond Mancy 2013-10-23 02:58:49 EDT
beaker 0.15.1 has been released.
Comment 9 Raymond Mancy 2013-10-23 03:02:47 EDT
This change has been nominated to be back ported to the 0.14 branch, to be released as part of the next maintenance release 0.14.2.
Comment 10 Nick Coghlan 2013-10-25 02:36:26 EDT
Adjusting target milestone to make the changes backported to 0.14.2 easier to identify. 0.15.0 has enough significant regressions that it shouldn't be used, so the change means that 0.15.1 can be effectively reidentified as the union of that tag and the 0.14.2 target milestone.
Comment 13 Nick Coghlan 2013-11-06 20:47:24 EST
Closing as addressed in Beaker 0.14.2.

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