Page MenuHomePhabricator

Different list API endpoints order the tools contained in the list differently
Closed, ResolvedPublicBUG REPORT

Description

  • /api/lists/{id}/ seems to return the tools in the order they were added in to the list
  • /api/lists/{list_pk}/revisions/{id}/ seems to return the tools in alphabetical order

Event Timeline

Change 777457 had a related patch set uploaded (by Raymond Ndibe; author: Raymond Ndibe):

[wikimedia/toolhub@main] api: same ordering for lists and list revision

https://gerrit.wikimedia.org/r/777457

This patch has a weird bug.

To reproduce:

  1. Create a new empty list.
  2. Add the tool "Wiki Loves Monuments maps" to it
  3. Go to MyLists: everything here looks good
  4. Go to the list's List History, click on the most recent Revision

Expected behavior:

There is a list with a "Wiki Loves Monuments maps" ToolCard in it.

What really happens:

There are several "Wiki Loves Monuments maps" ToolCards in the list.

I created three different lists, each containing the "Wiki Loves Monuments maps" tool. When inspecting the latest revision,

  • the first list had 2 "Wiki Loves Monuments maps" ToolCards
  • the second had 3
  • the third had 4!

Screenshot 2022-04-07 at 16.38.28.png (1×2 px, 185 KB)

I tried doing the same thing on the main branch, but everything worked fine there.

Yes this is a weird bug and really interesting reading about it. I went through a couple of django issues before discovering this a known won't fix issue and was opened and closed 10 years ago. here is the link https://code.djangoproject.com/ticket/18165.
The first solution that solves it satisfactorily is to use .distinct(), but I can't say with confidence that this is the best solution. I'll submit a match with the distinct() approach however. If someone knows of a better solution, I'd be glad to talk about it.

Change 777457 merged by jenkins-bot:

[wikimedia/toolhub@main] api: same ordering for lists and list revision

https://gerrit.wikimedia.org/r/777457

Change 786342 had a related patch set uploaded (by BryanDavis; author: Bryan Davis):

[operations/deployment-charts@master] toolhub: Bump container version to 2022-04-21-215651-production

https://gerrit.wikimedia.org/r/786342

Change 786342 merged by jenkins-bot:

[operations/deployment-charts@master] toolhub: Bump container version to 2022-04-21-215651-production

https://gerrit.wikimedia.org/r/786342