Page MenuHomePhabricator

🥨️ Create/replace a label in a given language on a property
Closed, ResolvedPublic8 Estimated Story Points

Description

Description
PUT /entities/properties/{property_id}/labels/{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}/labels/{language_code}.
  • If a label in the given language didn't exist before the successful request the response should use 201 code.
  • If the request changed the existing label 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}"}
Label contains invalid characters400"code": "invalid-label"
"message": "Not a valid label: {label}"
Label is empty 400 { "code": "label-empty", "message": "Label must not be empty" }
Label too long 400 { "code": "label-too-long", "message": "Label must be no more than {limit} characters long", "context": { "value": "{label}", "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}" } }
property has the exact same label as another property400 { "code": "property-label-duplicate", "message": "Property {dupe_id} already has label "{label}" associated with language code {language}", "context": { "language": "{language}", "label": "{label}","matching-property-id": "{duplicate_property_id}" }}
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}/labels/{language_code}
  • mul is a valid language code for a label but it is not allowed for descriptions
  • Handle HTTP conditional request headers as in PUT /entities/items/{item_id}/labels/{language_code}
  • Handle user authentication/authorization like in PUT /entities/items/{item_id}/labels/{language_code}

Task breakdown notes:

  • Add the new route to OAS.
  • create use case validation deserialization:
    • create PropertyLabelValidator interface and implement it (WikibaseRepoPropertyLabelValidator)
    • create PropertyLabelEditRequest interface
    • create PropertyLabelEditRequestValidatingDeserializer
    • rename TermValidatorFactoryLabelTextValidator to TermValidatorFactoryItemLabelTextValidator
    • create a new TermValidatorFactoryPropertyLabelTextValidator
  • 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 label
  • 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 Create/replace a label or description in a given language on a property to Create/replace a label in a given language on a property.Oct 4 2023, 2:50 PM
Ifrahkhanyaree_WMDE updated the task description. (Show Details)
Silvan_WMDE renamed this task from Create/replace a label in a given language on a property to 🥨️ Create/replace a label in a given language on a property.Oct 6 2023, 9:05 AM

Change 964875 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):

[mediawiki/extensions/Wikibase@master] REST: Add PUT property label route to OAS

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

Change 964876 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):

[mediawiki/extensions/Wikibase@master] REST: Add Labels to Property read model

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

Change 964888 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):

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

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

Change 964942 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):

[mediawiki/extensions/Wikibase@master] REST: Add request validation to SetPropertyLabel

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

Change 964875 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add PUT property label route to OAS

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

Change 964876 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add Labels to Property read model

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

Change 964888 merged by jenkins-bot:

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

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

Change 965706 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):

[mediawiki/extensions/Wikibase@master] REST: Add existence check to SetPropertyLabel

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

Change 965721 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):

[mediawiki/extensions/Wikibase@master] REST: Add Authorization to SetPropertyLabel

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

Change 965752 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):

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

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

Change 965760 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):

[mediawiki/extensions/Wikibase@master] REST: Add OpenAPI spec tests for SetPropertyLabel

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

Change 964942 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add request validation to SetPropertyLabel

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

Change 965706 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add existence check to SetPropertyLabel

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

Change 965721 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add Authorization to SetPropertyLabel

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

Change 965752 merged by jenkins-bot:

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

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

Change 965760 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Add OpenAPI spec tests for SetPropertyLabel

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

Works as expected, thank you

Scenarios tested:

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

Keeping the ticket open for the final verification by @Ifrahkhanyaree_WMDE

Change 966510 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):

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

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

Change 966510 merged by jenkins-bot:

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

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

  NODES
Note 7
Project 8