Page MenuHomePhabricator

Fix incorrect JSON pointers to root element in error responses
Closed, ResolvedPublic3 Estimated Story PointsBUG REPORT

Description

The JSON pointer to the root path is an empty string "", not "/". The REST API is currently doing this wrong in missing-field responses when validating that required top-level fields are present.

Technical notes:

  • the only piece of production code with this issue appears to be repo/rest-api/src/RouteHandlers/AssertValidTopLevelFields.php
  • the affected e2e tests can be found via grep -r "path: '/'" repo/rest-api/tests/mocha/ executed inside the wikibase dir. affected test files at the time of writing:
    • repo/rest-api/tests/mocha/api-testing/AddItemAliasesInLanguageTest.js
    • repo/rest-api/tests/mocha/api-testing/AddItemStatementTest.js
    • repo/rest-api/tests/mocha/api-testing/AddPropertyAliasesInLanguageTest.js
    • repo/rest-api/tests/mocha/api-testing/AddPropertyStatementTest.js
    • repo/rest-api/tests/mocha/api-testing/CreateItemTest.js
    • repo/rest-api/tests/mocha/api-testing/ReplaceItemStatementTest.js
    • repo/rest-api/tests/mocha/api-testing/ReplacePropertyStatementTest.js
    • repo/rest-api/tests/mocha/api-testing/SetItemDescriptionTest.js
    • repo/rest-api/tests/mocha/api-testing/SetItemLabelTest.js
    • repo/rest-api/tests/mocha/api-testing/SetPropertyDescriptionTest.js
    • repo/rest-api/tests/mocha/api-testing/SetPropertyLabelTest.js
    • repo/rest-api/tests/mocha/api-testing/SetSitelinkTest.js
    • repo/rest-api/tests/mocha/helpers/testValidatesPatch.js

Event Timeline

Jakob_WMDE renamed this task from Fix incorrect JSON pointers to root path in error responses to Fix incorrect JSON pointers to root element in error responses.Oct 18 2024, 12:46 PM
Ollie.Shotton_WMDE changed the subtype of this task from "Task" to "Bug Report".Oct 21 2024, 9:22 AM
Ollie.Shotton_WMDE subscribed.

Change #1084126 had a related patch set uploaded (by Muhammad Jaziraly; author: Muhammad Jaziraly):

[mediawiki/extensions/Wikibase@master] REST: Fix incorrect JSON pointers

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

Change #1084126 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Fix incorrect JSON pointers

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

Change #1089785 had a related patch set uploaded (by Ollie Shotton; author: Muhammad Jaziraly):

[mediawiki/extensions/Wikibase@REL1_43] REST: Fix incorrect JSON pointers

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

Change #1089785 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@REL1_43] REST: Fix incorrect JSON pointers

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