Page MenuHomePhabricator

⏱ Early stop processing request if input contains mismatching statement ID and ID of an item or a property
Closed, ResolvedPublic5 Estimated Story Points

Description

Description:
The statement ID contains the ID of the item or the property which is the "subject" of the statement. If the ID of the "subject" and the ID of the item and property provided in the request path do not match, the input is clearly invalid and it is clear that the Wikibase REST API will not be able to process the request and the API can early stop processing the request.

Acceptance criteria:

Suggested response: 400 error response

"code": "item-statement-id-mismatch" / "property-statement-id-mismatch"
"message": "IDs of the item and the statement do not match" / "IDs of the property and the statement do not match"
"context": { "item-id": "<ITEM_ID>", "statement-id": "<STATEMENT_ID>" } / { "property-id": "<PROPERTY_ID>", "statement-id": "<STATEMENT_ID>" }

Notes:
Endpoints this refers to:

  • GET, PUT, DELETE, PATCH /entities/items/{item_id}/statements/{statement_id}
  • GET, PUT, DELETE, PATCH /entities/properties/{property_id}/statements/{statement_id}

Task breakdown notes:

  • create two request interfaces that combine StatementIdRequest with ItemIdRequest and PropertyIdRequest respectively
  • create a new validator for these kinds of requests that checks the IDs
  • remove the corresponding checks from the wrapper use cases
  • e2e tests

Event Timeline

To do:

  • Add list of endpoints that this refers to
  • Change formatting of ticket

Thanks for making this more legible @Jakob_WMDE , question this would also be applicable to PATCH entities/properties/property_id, right?

@Ifrahkhanyaree_WMDE I don't think this should apply to PATCH entities/properties/property_id. Any modification of a statement ID, or an attempted creation of a statement with an ID should result in a statement-id-not-modifiable error when patching a property IMO.

Ollie.Shotton_WMDE renamed this task from Early stop processing request if input contains mismatching statement ID and ID of an item or a property to ⏱ Early stop processing request if input contains mismatching statement ID and ID of an item or a property.Apr 3 2024, 9:14 AM

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

[mediawiki/extensions/Wikibase@master] REST: Ensure that statement subject ID and entity ID match.

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

@Ifrahkhanyaree_WMDE I don't think this should apply to PATCH entities/properties/property_id. Any modification of a statement ID, or an attempted creation of a statement with an ID should result in a statement-id-not-modifiable error when patching a property IMO.

In @Ifrahkhanyaree_WMDE 's absence -- agreeing with this. Applyng the same logic to PATCH entities/properties/property_id (and respectively to the upcoming PATCH entities/items/{item_id} would require addition of non trivial logic. The benefit does not occur to justify the effort, so I'd agree to exclude it from the mentioned endpoints for the time being.

Change #1017119 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Ensure that statement subject ID and entity ID match.

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