Page MenuHomePhabricator

🟥️ Remove a statement of an item
Closed, ResolvedPublic8 Estimated Story Points

Description

As a tool developer I want to remove statements from an item so that my tool can remove incorrect data
As a gadget developer I want to remove statements from an item so that my tool can remove duplicated statements

DELETE /entities/items/{item_id}/statements/{statement_id}
DELETE /statements/{statement_id}

Responses:

  • On the successful removal, API should respond with 200 and "Statement deleted" as a response body.
    • 200 response should also contain Content-Language header with "en" as a value
  • If the statement with the request ID does not exist, API would respond with 404.
    • If the item requested (via item_id or identifiable in statement_id) has been merged and redirected into other item, it is also considered the situation that the statement does not exist, and the API would respond with 404.

Authenticating user and checking their permission to make a change (including on a protected item) are out of scope of this story, and will be addressed separately.

All editing REST API endpoints are meant to include a consistent "metadata" optional parameters

  • mediawiki "metadata" can be specified:
    • "comment" to be included in the edit summary
    • mediawiki tag(s) for the edit
    • flag edit as made by a bot
  • to help Wikibase solve potential edit conflict ("lost update problem"), the latest revision of an item known by a client when making the request can also be provided using If-Match HTTP header. In case the ETag provided is not the most recent version if the item, the API would response in 412 Precondition Failed response code.
    • As a timestamp-based counterpart, also used If-Unmodified-Since header with a respective logic.
    • 412 respond should not include any extra text in response body. The response should also not include ETag and Last-Modified header

For a possible inspiration could also see: https://wmde.github.io/wikibase-rest-api-proposal/#/statements/delete_statements__statement_id_ (non binding reference)

Event Timeline

WMDE-leszek set the point value for this task to 8.Jun 27 2022, 8:47 PM

*Task Breakdown notes*

  • add DELETE endpoint to OpenAPI document - task to be created by @Silvan_WMDE

subtask "happy path": to be created by @Silvan_WMDE

  • create a new RemoveItemStatement use case, including RemoveItemStatementRequest
  • retrieve Item metadata
  • remove the statement
    • use ItemRetriever, remove the statement, then save using MediaWikiEditEntityFactoryItemUpdater
    • create a RemoveItemStatementSuccessResponse and return it

subtask "validation": to be created by @Ollie.Shotton_WMDE

  • Validation
    • itemId (if present), statementId
    • return ErrorResponse in case of invalid item or statement IDs
    • ignore invalid conditional headers
    • use `EditMetadataValidator' to return ErrorResponse in case of invalid meta data

subtask "other error responses": to be created by @Ollie.Shotton_WMDE

  • return ErrorResponse in cases of notFound or redirect
  • return ErrorResponse in case of outdated If-Match revisionId or If-Unmodified-Since timestamp

subtask RouteHandler: to be created by @Silvan_WMDE

  • get parameters and create RemoveItemStatementRequest
  • execute the use case
  • handle use case responses (success/redirect/error)
  • return HTTP response
  • unexpected error handling
  • create e2e-tests
Silvan_WMDE renamed this task from Remove a statement of an item to 🟥️ Remove a statement of an item.Jul 7 2022, 1:55 PM

If-Match and If-Unmodified-Since do not seem to work on the "longer route" DELETE /entities/items/{item_id}/statements/{statement_id}

@WMDE-leszek: Assuming this task is resolved. Thus setting resolved task status. Please reopen and add an active project tag if that is not the case. Thanks.