Red Hat Bugzilla – Bug 906781
getusers doesn't return user list in the same order as the input list
Last modified: 2013-03-22 17:00:45 EDT
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 matches returns, userlist matches returns, 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(['firstname.lastname@example.org','email@example.com'])
> print users.email
The result might differ. Try with a bigger input list and you have a higher chance to see this.
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:
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.
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.
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.
python-bugzilla-0.8.0-1.fc18 has been submitted as an update for Fedora 18.
python-bugzilla-0.8.0-2.fc18 has been submitted as an update for Fedora 18.
* 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).
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.