Bug 951985

Summary: beaker-import explodes on failure to import a distro tree where the exception message contains %
Product: [Retired] Beaker Reporter: Dan Callaghan <dcallagh>
Component: lab controllerAssignee: Raymond Mancy <rmancy>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.12CC: asaha, dakini, dcallagh, dgeevarg, ebaak, llim, qwan, rglasz, rmancy, xjia
Target Milestone: 0.13   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-06-25 06:27:23 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:

Description Dan Callaghan 2013-04-15 01:21:37 UTC
Traceback (most recent call last):
  File "/usr/bin/beaker-import", line 9, in <module>
    load_entry_point('bkr.labcontroller==0.12.0', 'console_scripts', 'beaker-import')()
  File "/usr/lib/python2.6/site-packages/bkr/labcontroller/distro_import.py", line 1879, in main
    build.process(urls, opts)
  File "/usr/lib/python2.6/site-packages/bkr/labcontroller/distro_import.py", line 1734, in process
    raise BX('failed to add %s to beaker: %s' % (self.tree['name'],e))
  File "/usr/lib/python2.6/site-packages/bkr/common/bexceptions.py", line 4, in __init__
    self.value = value % args
TypeError: not enough arguments for format string

Exception is from bug 951981, the server-side exception contained a % from the parametrised MySQL query string from sqlalchemy.

I actually never noticed this behaviour in BX's constructor before, it's a little bit unconventional/unexpected. It means we may need to audit all usages of it to check for this same problem (passing non-constant strings as the message).

Comment 1 Raymond Mancy 2013-04-16 01:26:08 UTC
http://gerrit.beaker-project.org/#/c/1884/

Comment 3 xjia 2013-05-30 06:01:50 UTC
Base on https://bugzilla.redhat.com/show_bug.cgi?id=951981#c4 and I also check the code from beaker-devel environment. 
[root@lab-devel-03 ~]# cat  /usr/lib/python2.6/site-packages/bkr/common/bexceptions.py
class BeakerException(Exception):

   def __init__(self, value):
       self.value = value

   def __str__(self):
       return repr(self.value)

class BX(BeakerException):
   pass

Version:
[root@lab-devel-03 ~]# rpm -qf /usr/lib/python2.6/site-packages/bkr/common/bexceptions.py
beaker-0.12.1-1.git.133.6c74a92.el6.noarch

Comment 5 Amit Saha 2013-06-25 06:27:23 UTC
Beaker 0.13.1 has been released.