This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 906781 - getusers doesn't return user list in the same order as the input list
getusers doesn't return user list in the same order as the input list
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: python-bugzilla (Show other bugs)
18
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Will Woods
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-01 08:31 EST by Kamil Páral
Modified: 2013-03-22 17:00 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-03-22 17:00:36 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Kamil Páral 2013-02-01 08:31:23 EST
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@redhat.com','awilliam@redhat.com'])
> print users[0].email
'awilliam@redhat.com'

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 14:51:44 EST
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 15:54:58 EST
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 18:50:46 EST
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 04:06:17 EST
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 10:21:43 EST
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 17:13:10 EST
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 18:25:09 EST
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 17:00:45 EDT
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.