As a tool builder I want to be able to change descriptions of an item so that work in my tool can be saved back to Wikidata.
PATCH /entities/items/{item_id}/descriptions
Acceptance criteria:
- 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: /* wbeditentity-update-languages-short:0||LANGS */ (similar to patching labels of items)
- Handle HTTP conditional request headers as in PATCH /entities/items/{item_id}/labels
- Handle user authentication/authorization like in PATCH /entities/items/{item_id}/labels
Error cases to consider:
| error type | HTTP Response code | Response content |
|---|---|---|
| item with the given ID does not exist | 404 | "code": "item-not-found", "message": "Could not find an item with the ID: '{item_id}'" |
| ID provided is not a valid item ID | 400 | "code": "invalid-item-id", "message": "Not a valid item ID: '{item_id}'" |
| Item with the provided ID has been redirected to another item | 409 | "code": "redirected-item" "message": "Item {item_id} has been merged into {other_id}." |
| Invalid JSON patch (general error) | 400 | "code": "invalid-patch" "message": "The provided patch is invalid" |
| incorrect JSON patch operation | 400 | "code": "invalid-patch-operation" "message": "Incorrect JSON patch operation: '<op>'" "context": { "operation": <operation_object> } |
| invalid field type in JSON patch (either of op, path, from is not a string) | 400 | "code": "invalid-patch-field-type" "message": "The value of '<field>' must be of type string" "context": { "operation": <operation_object>, "field": <field> } |
| missing mandatory field in JSON patch (op, path, value, also from on copy/move patches) | 400 | "code": "missing-json-patch-field" "message": "Missing '<field>' in JSON patch" "context": { "operation": <operation_object>, "field": <field> } |
| Target of JSON Patch not found on the object | 409 | "code": "patch-target-not-found", "message": "Target '<target>' not found on the resource", "context": { "operation": <operation_object>, "field": <path> } |
| JSON Patch test operation failed | 409 | "code": "patch-test-failed", "message": "Test operation in the provided patch failed. At path '{path}' expected '{expected}', actual: '{actual}'", "context": { "operation": <operation_object>, "actual-value": <actual> } |
| After changes an invalid language code is used | 422 | "code": "patched-descriptions-invalid-language-code" "message": "Not a valid language code '{language_code}' in changed descriptions" "context": { "language": <language_code> } |
| After changes a description is invalid (empty, too long) | 422 | "code": "patched-description-empty"/"patched-description-too-long" "message": "Changed description for '{lang_code}' cannot be empty" / "Changed description for '{lang_code}' must not be more than '{limit}' characters long" "context": { "language": <language_code> "value": <label> (too long description case only) "character-limit": <limit> (too long description case only) } |
| After changes a description is invalid (not allowed characters used) | 422 | "code": "patched-description-invalid" "message": "Changed description for '{lang_code}' is not valid; '{description-text}'" "context": { "language": <language_code> "value": <description> } |
| After changes the item has the exact same label and description in a given language | 422 | "code": "patched-item-label-description-same-value" "message": "Label and description for language code {language} can not have the same value. "context": { "language": <language> } |
| After changes the item has the same description and label in a given language as an existing item | 422 | "code": "patched-item-description-label-duplicate" "message": "Item {dupe_id} already has description {description}" associated with language code {language}, using the same label." "context": { "language": <language> "label": <label> "description": <description> "matching-item-id": <dupe_item_id> } |
Notes:
- Modifying labels of an item - https://phabricator.wikimedia.org/T332739
- How "Action API" does it: not exactly the same mechanism, but a similar outcome can be achieved with the wbsetdescription API module.