Page MenuHomePhabricator

Create/replace description of property in a given language
Closed, ResolvedPublic8 Estimated Story Points

Description

Description
PUT /entities/properties/{property_id}/description/{language_code}

Acceptance criteria:

  • The respective successful responses should present the relevant data as a string -- similar to the responses of GET /entities/properties/{property_id}/descriptions/{language_code}.
  • If a description in the given language didn't exist before the successful request the response should use 201 code.
  • If the request changed the existing description, the response code should be 200.

Error cases to consider

HTTP response coderesponse 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": "{property-id}"}
Invalid language code 400 { "code": "invalid-language-code", "message": "Not a valid language code: {language_code}"}
Description contains invalid characters400"code": "invalid-description"
"message": "Not a valid description: {description}"
Description is empty 400 { "code": "description-empty", "message": "Description must not be empty" }
Description too long 400 { "code": "description-too-long", "message": "Description must be no more than {limit} characters long", "context": { "value": "{description}", "character-limit": "{limit}" } }
Label description same value 400 { "code": "label-description-same-value", "message": "Label and description for language code '{language}' can not have the same value", "context": { "language": "{language}" } }
Invalid edit tag400 { "code": "invalid-edit-tag", "message": "Invalid MediaWiki tag: {tag}" }
Comment too long400 {"code": "comment-too-long", "message": "Comment must not be longer than {limit} characters"}

Notes

  • Automated edit summaries similar as done for items: https://phabricator.wikimedia.org/T323813
  • client can provide additional edit metadata: mediawiki tags, edit summary text to append to the automated summary, and a bot edit flag, like in GET /entities/properties/{property_id}/descriptions/{language_code}
  • mul is a not allowed for descriptions
  • Handle HTTP conditional request headers as in PUT /entities/items/{item_id}/descriptions/{language_code}
  • Handle user authentication/authorization like in PUT /entities/items/{item_id}/descriptions/{language_code}

Task breakdown notes:

  • Add the new route to OAS.
  • create use case validation deserialization:
    • create PropertyDescriptionValidator interface and implement it (WikibaseRepoPropertyDescriptionValidator)
    • create PropertyDescriptionEditRequest interface
    • create PropertyDescriptionEditRequestValidatingDeserializer
    • rename TermValidatorFactoryDescriptionTextValidator to TermValidatorFactoryItemDescriptionTextValidator
    • create a new TermValidatorFactoryPropertyDescriptionTextValidator
  • happy path (with edit summary)
    • use the use case validator for deserialization only, but don't handle or test any errors it throws yet
    • ETag and Last-Modified
    • differentiate between 200 OK for replaced and 201 CREATED for a newly added description
  • Handle request validation errors
  • Respond 404 if property not found
  • Authorization
  • Use the usual middlewares and add the route handler to RouteHandlersTest
  • Add spec tests.
  • Mark as production ready.

Event Timeline

Ifrahkhanyaree_WMDE renamed this task from WIP - Create/replace description of property in a given language to Create/replace description of property in a given language.Oct 4 2023, 3:08 PM
Ifrahkhanyaree_WMDE updated the task description. (Show Details)
Ifrahkhanyaree_WMDE set the point value for this task to 8.

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

[mediawiki/extensions/Wikibase@master] REST: Add SetPropertyDescription to OAS

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

Change 963663 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add SetPropertyDescription to OAS

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

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

[mediawiki/extensions/Wikibase@master] REST: Create validation and deserialization for SetPropertyDescription

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

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

[mediawiki/extensions/Wikibase@master] REST: SetPropertyDescription happy path

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

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

[mediawiki/extensions/Wikibase@master] REST: Handle SetPropertyDescription validation errors

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

Change 964424 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Create validation and deserialization for SetPropertyDescription

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

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

[mediawiki/extensions/Wikibase@master] REST: Property existence check in SetPropertyDescription

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

Change 964880 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: SetPropertyDescription happy path

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

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

[mediawiki/extensions/Wikibase@master] REST: Add Authorization to SetPropertyDescription use case

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

Change 965050 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Handle SetPropertyDescription validation errors

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

Change 965509 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Property existence check in SetPropertyDescription

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

Change 965655 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add Authorization to SetPropertyDescription use case

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

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

[mediawiki/extensions/Wikibase@master] REST: Add SetPropertyDescription middlewares

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

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

[mediawiki/extensions/Wikibase@master] REST: Add SetPropertyDescription spec tests

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

Change 965768 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add SetPropertyDescription middlewares

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

Change 966032 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add SetPropertyDescription spec tests

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

Looks good, thank you!

Scenarios tested:

  • adding a description in a language that didn't have description defined
  • changing a description in a language that already had a description
  • automated edit summary for both cases
  • response code for both cases
  • property does not exist
  • invalid property ID
  • invalid language code
  • description empty
  • description too long
  • description contains illegal characters
  • specifying edit metadata: mediawiki tag, additional edit comment text
  • invalid mediawiki tag
  • additional edit comment invalid
  • setting description to the same value as a label in the given language is forbidden
  • authentication/authorization
  • HTTP conditional headers

Leaving the ticket open for @Ifrahkhanyaree_WMDE final verification.

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

[mediawiki/extensions/Wikibase@master] REST: Mark SetPropertyDescription as production-ready

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

Change 966434 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Mark SetPropertyDescription as production-ready

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