Bug 906781 - getusers doesn't return user list in the same order as the input list
Summary: getusers doesn't return user list in the same order as the input list
Alias: None
Product: Fedora
Classification: Fedora
Component: python-bugzilla
Version: 18
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Will Woods
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2013-02-01 13:31 UTC by Kamil Páral
Modified: 2013-03-22 21:00 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2013-03-22 21:00:36 UTC
Type: Bug

Attachments (Terms of Use)

Description Kamil Páral 2013-02-01 13:31:23 UTC
Description of problem:
This is the documentation of bugzilla.RHBugzilla4.getusers:

> getusers(self, userlist)
>     Unbound RHBugzilla4 method
> Return a list of Users from bugzilla.
> :userlist: List of usernames to lookup
> :returns: List of User records

One would _assume_ that userlist[0] matches returns[0], userlist[1] matches returns[1], etc. It doesn't. The returned list ordering doesn't match the input userlist order.

Fortunately I discovered this before I put my code into production. As a workaround I'll have to go through the returned list item by item and match the user data manually. But you know what, this is very uncool.

Can you please fix it to keep the user ordering intact? Thanks.

Version-Release number of selected component (if applicable):

Steps to Reproduce:
> import bugzilla
> bz = bugzilla.RHBugzilla4(url='https://bugzilla.redhat.com/xmlrpc.cgi')
> users = bz.getusers(['kparal@redhat.com','awilliam@redhat.com'])
> print users[0].email

The result might differ. Try with a bigger input list and you have a higher chance to see this.

Comment 1 Cole Robinson 2013-02-01 19:51:44 UTC
Really this should be a request against Bugzilla, since we just forward on the data that was returned to us. But it was pretty simple to handle it in python-bugzilla, fixed upstream now:


Comment 2 Don Zickus 2013-02-01 20:54:58 UTC
You have to be careful here.  As all bugzilla data comes back unordered.  getusers is just the tip of the iceberg.  Unless you plan on re-arranging all returned data (including bugzillas themselves).  

Also what about the case where one of the requested users doesn't exist, then bugzilla just drops it.  So Cole's solution won't work either.

I am not sure the best way to solve this other than sort both lists and compare them individually before printing them.


Comment 3 Cole Robinson 2013-02-02 23:50:46 UTC
Yeah I probably should have just said WONTFIX but I was in this area of the code anyways. But I won't honor any requests to reorder data going forward.

As far as a requested user not being returned in the list, at least with the way python-bugzilla invokes Users.get(), an exception is thrown if a queried user is not found.

But yeah, generally any apps should just assume that the returned data is in random order, as you would if talking straight to xmlrpc.

Comment 4 Kamil Páral 2013-02-04 09:06:17 UTC
I didn't know this is a "feature" of Bugzilla itself.

_But_, could you please at least state in documentation to all methods related to this issue that the returned list is in a random order? That will save many python-bugzilla users from ugly surprises.

It is not hard to work around this issue in your code, it is just completely unexpected.

Comment 5 Fedora Update System 2013-02-16 15:21:43 UTC
python-bugzilla-0.8.0-1.fc18 has been submitted as an update for Fedora 18.

Comment 6 Fedora Update System 2013-03-04 22:13:10 UTC
python-bugzilla-0.8.0-2.fc18 has been submitted as an update for Fedora 18.

Comment 7 Fedora Update System 2013-03-05 23:25:09 UTC
Package python-bugzilla-0.8.0-2.fc18:
* should fix your issue,
* was pushed to the Fedora 18 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.8.0-2.fc18'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).

Comment 8 Fedora Update System 2013-03-22 21:00:45 UTC
python-bugzilla-0.8.0-2.fc18 has been pushed to the Fedora 18 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.