Page MenuHomePhabricator

🦜 Replace data of a statement on a property
Closed, ResolvedPublic8 Estimated Story Points

Description

As a tool developer I want to be able to replace data of a statement on a property so that my tool can store modifications made by its users

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

Notes

  • "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 PUT /entities/items/{item_id}/statements/{statement_id}
  • Handle user authentication/authorization like in PUT /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-put_entities_items__item_id__statements__statement_id_
  • client can provide additional edit metadata: mediawiki tags, edit summary text to append to the automated summary, and a bot edit flag, like in PUT /entities/items/{item_id}/statements/{statement_id}

Error cases to consider

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"
Data of a statement missing mandatory field400"code": "statement-data-missing-field"
"message": "Mandatory field missing in the statement data: '{field}'"
"context": { "path": "{field}"}
Value provided in statement data is invalid, incl the case when the property used is a well-formed ID but this property does not exist400"code": "statement-data-invalid-field"
"message": "Invalid input for '{field}'"
"context": { "path": "{field}", "value": "{value}"}
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"
Request payload is not JSON415"code": "unsupported-content-type"
"message": "Unsupported Content-Type: '{content_type}'"

Possibly relevant pointers:

Event Timeline

WMDE-leszek changed the edit policy from "Custom Policy" to "All Users".
Jakob_WMDE set the point value for this task to 8.Jul 21 2023, 10:10 AM

Task breakdown

  • Add new replace property statement route to OAS doc
  • Create new Statement Updater service
  • Refactor the ReplaceItemStatement use case to ReplaceStatement
    • Rename use case and its related classes
    • Create a new use case step AssertStatementSubjectExists
  • Make the ReplaceStatement use case subject agnostic
    • Update the validator to support all subject ids
    • Use the Statement Updater service
  • Add new long route and update existing short route
    • Add route handler for long route
    • Create e2e test suite for replacing a statement on a property (long and short)
  • Add schema tests
  • Mark the new replace property statement (long) route as production ready
Ollie.Shotton_WMDE renamed this task from Replace data of a statement on a property to 🦜 Replace data of a statement on a property.Jul 27 2023, 1:45 PM

Prod verification summary:

Used: P3586 on Beta wikidata

  • PUT requests using both endpoints worked (PUT /entities/properties/.. and PUT /statements/..)
  • Edit summary is the same as for statement on items
  • Metadata can be added
  • HTTP conditional requests and authentication works
  • All errors work except/I have open questions for:
    • Edit comment/summary too long: It gave me a statement data invalid message (hadn't used any special characters)
    • "..incl the case when the property used in the statement is a well-formed ID but this property does not exist" - I couldn't get this message, not sure what I must mess around with?

Checked after the daily:

  • Edit comment/summary too long: works perfectly
  • "..incl the case when the property used in the statement is a well-formed ID but this property does not exist" - Also works perfectly

Moving to Done