Page MenuHomePhabricator

Wikibase REST API: PATCHing a list doesn't maintain its order
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue:

  • Create or modify an Item to have the following English aliases [ "an en alias", "alias in English", "another alias" ]
  • Send a PATCH /entities/items/{{ item_id }}/aliases request that replaces the first alias in the list. E.g.:
{
  "patch": [
    {
      "op": "replace",
      "path": "/en/0",
      "value": "a changed alias"
    }
  ]
}

What happens?:

{
  "en": [
    "alias in English",
    "another alias",
    "a changed alias"
  ]
}

What should have happened instead?:

The response from the PATCH /entities/items/{{ item_id }}/aliases request should maintain the order of the list

{
  "en": [
    "a changed alias",
    "alias in English",
    "another alias"
  ]
}

Other information

  • Modifying an object in a list works as expected - the issue seems to exist when replacing a whole list item
  • I believe this is due to the swaggest/json-diff library we are using

Event Timeline

Ollie.Shotton_WMDE changed the task status from Open to Stalled.Nov 1 2023, 9:36 AM

Someone else beat me to it. PR to fix this issue in the upstream json-diff library was submitted July 7th 2023: https://github.com/swaggest/json-diff/pull/65

Ollie.Shotton_WMDE changed the task status from Stalled to Open.Nov 17 2023, 3:31 PM

Upstream library merged the fix in PR67 and released v3.10.5

Change 975314 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):

[mediawiki/vendor@master] Bump swaggest/json-diff to 3.10.5

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

Change 975301 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):

[mediawiki/extensions/Wikibase@master] REST: Fix patched lists being reordered

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

Change 975314 merged by jenkins-bot:

[mediawiki/vendor@master] Bump swaggest/json-diff to 3.10.5

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

Change 975301 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Fix patched lists being reordered

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