Page MenuHomePhabricator

🏴‍☠️ Modify data of a statement on a property
Closed, ResolvedPublic8 Estimated Story Points

Description

As a tool developer I want to change elements of a statement so that my tool can improve ontology on Wikibase instance

PATCH /entities/properties/{property_id}/statements/{statement_id}
PATCH /statements/{statement_id}

Notes

  • Request includes a JSON Patch document describing wanted changes
    • client can provide additional edit metadata: mediawiki tags, edit summary text to append to the automated summary, and a bot edit flag, like in PATCH /entities/items/{item_id}/statements/{statement_id}
  • Response to a success request will include the new statement data, inclduing the ETag (revision ID) and modification timestamp
  • "Automated edit summary" related to the edit to be of form: /* wbsetclaim-update:1||1 */ [[Property:P123]]: VALUE_FORMATTED (exactly the same thing as for statement on items)
  • Handle HTTP conditional request headers as in PATCH /entities/items/{item_id}/statements/{statement_id}
  • Handle user authentication/authorization like in PATCH /entities/items/{item_id}/statements/{statement_id}
  • The functionality already exist for statements on items: https://doc.wikimedia.org/Wikibase/master/js/rest-api/#operations-statements-patch_entities_items__item_id__statements__statement_id_
    • Story about adding PATCH route for a statement on an item: T306934
    • Story about edit summaries, involving the PATCH method: T312811

Error cases to consider (expected to match the errors of PATCH /entities/items/{item_id}/statements/{statement_id})

HTTP response coderesponse payload
Property does not exist - the "statement subject" property 404"code": "property-not-found"
"message": "Could not find a property with the ID: {property_id}"
Statement does not exist404"code": "statement-not-found"
"message": "Could not find a statement with the ID: {statement_id}"
Invalid statement ID400"code": "invalid-statement-id"
"message": "Not a valid statement ID: {statement_id}"
Invalid property ID - the "statement subject" property400"code": "invalid-property-id"
"message": "Not a valid property ID: {property_id}"
"context": {"property-id": "{property-id}"}
Invalid edit tag400"code": "invalid-edit-tag"
"message": "Invalid MediaWiki tag: {tag}"
Edit comment/summary too long400"code": "comment-too-long"
"message": "Comment must not be longer than {limit} characters"
Request would change the ID of the statement400"code": "invalid-operation-change-statement-id"
"message": "Cannot change the ID of the existing statement"
Request would change the property (predicate) of the statement400"code": "invalid-operation-change-property-of-statement"
"message": "Cannot change the property of the existing statement"
Missing a mandatory field in JSON Patch (e.g. "path", "op")400"code": "missing-json-patch-field"
"message": "Missing '{field}' in JSON patch"
"context": { "operation": { <PATCH_OBJECT> }, "field": <MISSING_FIELD> }
Operation in the JSON Patch is not valid400"code": "invalid-patch-operation"
"message": "Incorrect JSON patch operation: '{op}'"
"context": { "op": "{op}", path": "/some/path" }
Value provided in the JSON Patch operation is of incorrect type400"code": "invalid-patch-field-type"
"message": "The value of '{field}' must be of type string"
"context": { "operation": { <PATCH_OBJECT> }, "field": <FIELD> }
Provided JSON Patch document is not valid (generic error)400"code": "invalid-patch"
"message": "The provided patch is invalid"
Cannot apply JSON Patch as target path not found409"code": "patch-target-not-found"
"message": "Target '{target}' not found on the resource"
"context": { "operation": { <PATCH_OBJECT> }, "field": <PATH> }
Test operation of JSON Patch failed409"code": "patch-test-failed"
"message": "Test operation in the provided patch failed. At path '{path}' expected '{expected}', actual: '{actual}'"
"context": { "operation": { <PATCH_OBJECT> }, "actual-value": <ACTUAL> }
Request payload is not JSON415"code": "unsupported-content-type"
"message": "Unsupported Content-Type: '{content_type}'"
Statement after changes missing mandatory field422"code": "patched-statement-missing-field"
"message": "Mandatory field missing in the patched statement: '{field}''"
"context": { "path": "{field}"}
Value in the statement data after changes is invalid422"code": "patched-statement-invalid-field"
"message": "Invalid input for '{field}' in the patched statement"
"context": { "path": "{field}", "value": "{value}"}
.........

Possibly relevant pointers:

Event Timeline

Jakob_WMDE set the point value for this task to 8.Jul 21 2023, 10:20 AM

Task breakdown

  • Add new patch property statement route to OAS doc - @Silvan_WMDE
  • Make the newly renamed PatchStatement use case subject agnostic - @Jakob_WMDE
    • Use Statement Updater
  • Create a PatchPropertyStatement wrapper use case - @Muhammad_Yasser_Jazirahly_WMDE
    • Add route handler for long route
    • Create e2e test suite for patching a statement on a property (long and short)
  • Add schema tests - @Ollie.Shotton_WMDE
  • Mark the new patch property statement (long) route as production ready - @Silvan_WMDE
Silvan_WMDE renamed this task from Modify data of a statement on a property to 🏴‍☠️ Modify data of a statement on a property.Aug 22 2023, 1:37 PM