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
- 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
- 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** (expected to match the errors of `PATCH /entities/items/{item_id}/statements/{statement_id}`)
<table>
<tr>
<th>
</th>
<th>HTTP response code</th>
<th>response payload</th>
</tr>
<tr>
<td>Property does not exist - the "statement subject" property </td>
<td>404</td>
<td>
`"code": "property-not-found"`
`"message": "Could not find a property with the ID: {property_id}"`
</td>
</tr>
<tr>
<td>Statement does not exist</td>
<td>404</td>
<td>
`"code": "statement-not-found"`
`"message": "Could not find a statement with the ID: {statement_id}"`
</td>
</tr>
<tr>
<td>Invalid property ID - the "statement subject" property</td>
<td>400</td>
<td>
`"code": "invalid-property-id"`
`"message": "Not a valid property ID: {property_id}"`
`"context": {"property-value-id": "{property-id}"}`
</td>
</tr>
<tr>
<td>Invalid edit tag</td>
<td>400</td>
<td>
`"code": "invalid-edit-tag"`
`"message": "Invalid MediaWiki tag: {tag}"`
</td>
</tr>
<tr>
<td>Edit comment/summary too long</td>
<td>400</td>
<td>
`"code": "comment-too-long"`
`"message": "Comment must not be longer than {limit} characters"`
</td>
</tr>
<tr>
<td>Request would change the ID of the statement</td>
<td>400</td>
<td>
`"code": "invalid-operation-change-statement-id"`
`"message": "Cannot change the ID of the existing statement"`
</td>
</tr>
<tr>
<td>Request would change the property (predicate) of the statement</td>
<td>400</td>
<td>
`"code": "invalid-operation-change-property-of-statement"`
`"message": "Cannot change the property of the existing statement"`
</td>
</tr>
<tr>
<td>Missing a mandatory field in JSON Patch (e.g. "path", "op")</td>
<td>400</td>
<td>
`"code": "missing-json-patch-field"`
`"message": "Missing '{field}' in JSON patch"`
`"context": { "operation": { <PATCH_OBJECT> }, "field": <MISSING_FIELD> }`
</td>
</tr>
<tr>
<td>Operation in the JSON Patch is not valid</td>
<td>400</td>
<td>
`"code": "invalid-patch-operation"`
`"message": "Incorrect JSON patch operation: '{op}'"`
`"context": { "op": "{op}", path": "/some/path" }`
</td>
</tr>
<tr>
<td>Value provided in the JSON Patch operation is of incorrect type</td>
<td>400</td>
<td>
`"code": "invalid-patch-field-type"`
`"message": "The value of '{field}' must be of type string"`
`"context": { "operation": { <PATCH_OBJECT> }, "field": <FIELD> }`
</td>
</tr>
<tr>
<td>Provided JSON Patch document is not valid (generic error)</td>
<td>400</td>
<td>
`"code": "invalid-patch"`
`"message": "The provided patch is invalid"`
</td>
</tr>
<tr>
<td>Cannot apply JSON Patch as target path not found</td>
<td>409</td>
<td>
`"code": "patch-target-not-found"`
`"message": "Target '{target}' not found on the resource"`
`"context": { "operation": { <PATCH_OBJECT> }, "field": <PATH> }`
</td>
</tr>
<tr>
<td>Test operation of JSON Patch failed</td>
<td>409</td>
<td>
`"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> }`
</td>
</tr>
<tr>
<td>Request payload is not JSON</td>
<td>415</td>
<td>
`"code": "unsupported-content-type"`
`"message": "Unsupported Content-Type: '{content_type}'"`
</td>
</tr>
<tr>
<td>Statement after changes missing mandatory field</td>
<td>422</td>
<td>
`"code": "patched-statement-missing-field"`
`"message": "Mandatory field missing in the patched statement: '{field}''"`
`"context": { "path": "{field}"}`
</td>
</tr>
<tr>
<td>Value in the statement data after changes is invalid</td>
<td>422</td>
<td>
`"code": "patched-statement-invalid-field"`
`"message": "Invalid input for '{field}' in the patched statement"`
`"context": { "path": "{field}", "value": "{value}"}`
</td>
</tr>
<tr>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
</table>
**Possibly relevant pointers:**
* Suggestion in 2020 Wikibase REST API proposal: https://wmde.github.io/wikibase-rest-api-proposal/#/statements/patch_statements__statement_id_
* How Wikibase Action API handles this: https://www.wikidata.org/w/api.php?action=help&modules=wbsetclaim