As a developer I want to be able to edit a Wikidata property
PATCH /entities/properties/{property_id}
Acceptance criteria
- Request payload to be the same as the one for PATCH /entities/items/{item_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 PATCH /entities/items/{item_id}
- Response to a success request will include the new statement data, including the ETag (revision ID) and modification timestamp
- Handle HTTP conditional request headers as in PATCH /entities/items/{item_id}
- Handle user authentication/authorization like in PATCH /entities/items/{item_id}
- Edit summaries to be similar to that of https://phabricator.wikimedia.org/T342993
Error cases to consider
HTTP response code | response payload | |
---|---|---|
Property does not exist | 404 | "code": "property-not-found" "message": "Could not find a property with the ID: {property_id}" |
Invalid property ID | 400 | "code": "invalid-property-id" "message": "Not a valid property ID: {property_id}" "context": {"property-id": "{property-id}"} |
Request would change the ID of the property | 422 | "code": "patched-property-invalid-operation-change-property-id" "message": "Cannot change the ID of the existing property" |
Request would change the data type of the property | 422 | "code": "patched-property-invalid-operation-change-property-datatype" "message": "Cannot change the datatype of the existing property" |
Missing a mandatory field in JSON Patch (e.g. "path", "op") | 400 | "code": "missing-json-patch-field" "message": "Missing '{field}' in JSON patch" "context": { "operation": { <PATCH_OBJECT> }, "field": <MISSING_FIELD> } |
Operation in the JSON Patch is not valid | 400 | "code": "invalid-patch-operation" "message": "Incorrect JSON patch operation: '{op}'" "context": { "op": "{op}", path": "/some/path" } |
Value provided in the JSON Patch operation is of incorrect type | 400 | "code": "invalid-patch-field-type" "message": "The value of '{field}' must be of type string" "context": { "operation": { <PATCH_OBJECT> }, "field": <FIELD> } |
Provided JSON Patch document is not valid (generic error) | 400 | "code": "invalid-patch" "message": "The provided patch is invalid" |
Cannot apply JSON Patch as target path not found | 409 | "code": "patch-target-not-found" "message": "Target '{target}' not found on the resource" "context": { "operation": { <PATCH_OBJECT> }, "field": <PATH> } |
Test operation of JSON Patch failed | 409 | "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> } |
Request payload is not JSON | 415 | "code": "unsupported-content-type" "message": "Unsupported Content-Type: '{content_type}'" |
Property after changes missing mandatory field | 422 | "code": "patched-property-missing-field" "message": "Mandatory field missing in the patched property: '{field}''" "context": { "path": "{field}"} |
Value in the property data after changes is invalid | 422 | "code": "patched-property-invalid-field" "message": "Invalid input for '{field}' in the patched property" "context": { "path": "{field}", "value": "{value}"} |
Unexpected field for property in patch request | 422 | "code": " patched-property-unexpected-field" "message": "The patched property contains an unexpected field: {"field"}" |
Statement id cannot be added or changed | 422 | "code": "statement-id-not-modifiable" "message": "Statement IDs cannot be created or modified" "context": "{"statement-id":"{statement_id}" } |
Property of a statement cannot be changed | 422 | "code": "patched-statement-property-not-modifiable" "message": "Property of a statement cannot be modified" "context": "{"statement-id":"{statement_id}", "statement-property-id": "{property_of_statement_as_persisted}" } |
Invalid edit tag | 400 | { "code": "invalid-edit-tag", "message": "Invalid MediaWiki tag: {tag}" } |
Comment too long | 400 | {"code": "comment-too-long", "message": "Comment must not be longer than {limit} characters"} |
Invalid statement group object | 422 | "code": "patched-invalid-statement-group-type" "message": "Not a valid statement group" "context": { "path": "{property_id}" } |
Invalid statement object | 422 | "code": "patched-invalid-statement-type" "message": "Not a valid statement type" "context": { "path": "{property_id}/{index}" } |
Statement's Property ID value does not match the key of the statement group | 422 | "code": "patched-statement-group-property-id-mismatch" "message": "Statement's Property ID does not match the statement group key" "context": { "path": "{property_id_key}/{index}/property/id", "statement-group-property-id": "{property_id_key}", "statement-property-id": "{property_id_value}" } |
Possibly relevant pointers:
- How Wikibase Action API handles this: https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity
- PATCH labels specific errors: https://doc.wikimedia.org/Wikibase/master/js/rest-api/#/labels/patchPropertyLabels (everything under 422).
- PATCH description specific errors: https://doc.wikimedia.org/Wikibase/master/js/rest-api/#/descriptions/patchPropertyDescriptions (everything under 422, same as the ones for labels)
- PATCH aliases specific errors: https://doc.wikimedia.org/Wikibase/master/js/rest-api/#/aliases/patchPropertyAliases (everything under 422)
- PATCH statements specific errors: https://doc.wikimedia.org/Wikibase/master/js/rest-api/#/statements/patchPropertyStatement (under 400: change id and change property, under 422, under 409)