Bug 906781

Summary: getusers doesn't return user list in the same order as the input list
Product: [Fedora] Fedora Reporter: Kamil Páral <kparal>
Component: python-bugzillaAssignee: Will Woods <wwoods>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 18CC: crobinso, dzickus, jskarvad, wwoods
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-22 21:00:36 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 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):
python-bugzilla-0.7.0-3.fc18.noarch

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

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:

http://git.fedorahosted.org/cgit/python-bugzilla.git/commit/?id=85e93ec63e3fa07b9b0a2a1501589a360c4b5b1b

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.

Cheers,
Don

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.
https://admin.fedoraproject.org/updates/python-bugzilla-0.8.0-1.fc18

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.
https://admin.fedoraproject.org/updates/python-bugzilla-0.8.0-2.fc18

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:
https://admin.fedoraproject.org/updates/FEDORA-2013-3447/python-bugzilla-0.8.0-2.fc18
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.