Bug 787411 - get_flag_type API is busted with current RH bugzilla
Summary: get_flag_type API is busted with current RH bugzilla
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-bugzilla
Version: 16
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Will Woods
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-02-04 22:51 UTC by Cole Robinson
Modified: 2012-06-30 22:05 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-30 22:05:42 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Cole Robinson 2012-02-04 22:51:14 UTC
This may be an actual bugzilla bug, not positive. Reproducer:

$ cat test.py
import bugzilla

BZURL = 'https://bugzilla.redhat.com/xmlrpc.cgi'

bzapi = bugzilla.RHBugzilla3(url=BZURL)

bug = bzapi.query({"bug_id" : "579899"})[0]

print bug.get_flag_type("needinfo")

$ python test.py 
Traceback (most recent call last):
  File "test.py", line 9, in <module>
    print bug.get_flag_type("needinfo")
  File "/usr/lib/python2.7/site-packages/bugzilla/base.py", line 1364, in get_flag_type
    for t in self.flag_types:
  File "/usr/lib/python2.7/site-packages/bugzilla/base.py", line 1216, in __getattr__
    raise AttributeError, "field %s not in bugzilla.bugfields" % name
AttributeError: field flag_types not in bugzilla.bugfields



bugfields here is:

['alias', 'assigned_to', 'attach_data.thedata', 'attachments.description', 'attachments.filename', 'attachments.isobsolete', 'attachments.ispatch', 'attachments.isprivate', 'attachments.isurl', 'attachments.mimetype', 'attachments.submitter', 'attachstatusdefs.name', 'blocked', 'bug_file_loc', 'bug_group', 'bug_id', 'bug_severity', 'bug_status', 'build_id', 'cc', 'cclist_accessible', 'class', 'classification', 'clone_of', 'commenter', 'comments', 'component', 'conditional_nak', 'content', 'creation_ts', 'crm', 'cust_facing', 'days_elapsed', 'deadline', 'delta_ts', 'dependson', 'devel_whiteboard', 'documentation_action', 'environment', 'estimated_time', 'everconfirmed', 'ext_bz_bug_map.ext_bz_bug_id', 'external_bugzilla.description', 'external_bugzilla.url', 'extra_component', 'extra_version', 'fixed_in', 'flagtypes.name', 'groups', 'internal_whiteboard', 'issuetracker', 'keywords', 'last_closed', 'longdesc', 'longdescs.isprivate', 'mount_type', 'op_sys', 'owner_idle_time', 'partner', 'password', 'percentage_complete', 'priority', 'product', 'qa_contact', 'qa_whiteboard', 'qe_conditional_nak', 'regression_status', 'release_notes', 'remaining_time', 'rep_platform', 'reporter', 'reporter_accessible', 'requestees.login_name', 'resolution', 'see_also', 'setters.login_name', 'short_desc', 'status_whiteboard', 'story_points', 'target_milestone', 'target_release', 'targetrelease', 'type', 'vcs_commits', 'verified', 'verified_branch', 'version', 'view', 'votes', 'work_time']


The following diff against upstream makes it work:

$ git diff
diff --git a/bugzilla/base.py b/bugzilla/base.py
index f4707e0..14e3d2e 100644
--- a/bugzilla/base.py
+++ b/bugzilla/base.py
@@ -1361,7 +1361,9 @@ class _Bug(object):
         #XXX: make a "flag index" dictionary instead of walking the
         #     flag_types list every time?
 
-        for t in self.flag_types:
+        self.refresh()
+        flag_types = self.__dict__["flag_types"]
+        for t in flag_types:
             if t['name'] == name:
                 return t
 
So is the problem just that the bugzilla api getBugFields isn't returning flag_types ? I assume this worked at some point...

Comment 1 Ales Zelinka 2012-03-20 18:46:13 UTC
I have the same problem:

>>> buglist = bugzilla.query({'bug_id':758416})
>>> buglist[0].get_flags('devel_ack')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/bugzilla/base.py", line 1368, in get_flags
    ft = self.get_flag_type(name)
  File "/usr/lib/python2.6/site-packages/bugzilla/base.py", line 1358, in get_flag_type
    for t in self.flag_types:
  File "/usr/lib/python2.6/site-packages/bugzilla/base.py", line 1210, in __getattr__
    raise AttributeError, "field %s not in bugzilla.bugfields" % name
AttributeError: field flag_types not in bugzilla.bugfields


This works in python-bugzilla-0.6.0-1.el6.noarch.

Comment 2 Ales Zelinka 2012-06-04 12:16:52 UTC
Will, the patch from c#0 fixes the problem for us. Can you please apply it? Thanks.

Comment 3 Jan Ščotka 2012-06-04 12:17:31 UTC
Hi,
I have same problem, And it causes big problem in out tests automation,. I'm unable to read flags.
Is there any progress?
   Thanks
   Honza

Comment 4 Cole Robinson 2012-06-04 22:57:30 UTC
Current upstream is still busted here. I have a branch though at

git://fedorapeople.org/~crobinso/python-bugzilla.git tests

Which fixes it (along with a lot of other changes). I mailed wwoods about that branch so hopefully it will end up on master in due time.

Comment 5 Fedora Update System 2012-06-06 23:20:20 UTC
python-bugzilla-0.7.0-1.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/python-bugzilla-0.7.0-1.fc16

Comment 6 Fedora Update System 2012-06-07 22:51:55 UTC
Package python-bugzilla-0.7.0-1.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing python-bugzilla-0.7.0-1.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-8996/python-bugzilla-0.7.0-1.fc16
then log in and leave karma (feedback).

Comment 7 Fedora Update System 2012-06-30 22:05:42 UTC
python-bugzilla-0.7.0-1.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.


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