Bug 1014623

Summary: poor handling of utf-8 strings in bkr client
Product: [Retired] Beaker Reporter: Martin Kyral <mkyral>
Component: command lineAssignee: Dan Callaghan <dcallagh>
Status: CLOSED CURRENTRELEASE QA Contact: tools-bugs <tools-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.14CC: aigao, asaha, dcallagh, jingwang, jkejda, llim, qwan, rmancy, xjia
Target Milestone: 0.14.2Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-07 01:47:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
encode myxml to utf-8 upon creation none

Description Martin Kyral 2013-10-02 12:29:57 UTC
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-03 02:02:49 UTC
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-15 00:41:02 UTC
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 06:58:49 UTC
beaker 0.15.1 has been released.

Comment 9 Raymond Mancy 2013-10-23 07:02:47 UTC
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 06:36:26 UTC
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-07 01:47:24 UTC
Closing as addressed in Beaker 0.14.2.