Page MenuHomePhabricator

☃️ Create/Add aliases in a given language for a property
Closed, ResolvedPublic8 Estimated Story Points

Description

Description
POST /entities/properties/{property_id}/aliases/{language_code}

request payload

{ 
  "aliases": [ "ALIAS_TEXT", ... ]
 ...
}

Acceptance criteria:

  • The respective successful responses should present the list of aliases in a given language -- similar to the responses of GET /entities/properties/{property_id}/aliases/{language_code}.
  • If there was no aliases in the given language before the successful request the response should use 201 code, otherwise 200.

Error cases to consider

HTTP response coderesponse payload
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}"
Alias contains invalid characters400"code": "invalid-alias"
"message": "Not a valid alias: '{alias}'"
"context": {
"alias": <alias>
}
Alias is empty 400"code": "alias-empty"
"message": "Alias must not be empty"
Alias list is empty 400"code": "alias-list-empty"
"message": "Alias list must not be empty"
Alias too long 400"code": "alias-too-long"
"message": "Alias must be no more than {limit} characters long"
"context": {
"value": "{alias}",
"character-limit": "{limit}"
}
Alias duplicate 400"code": "duplicate-alias"
"message": "Alias list contains a duplicate alias: '{alias}'"
"context": { "alias": "{alias}" }
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"
Property does not exist 404"code": "property-not-found"
"message": "Could not find a property with the ID: {property_id}"

Notes

  • Automated edit summaries similar as done for items: T335842
  • 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}/alias/{language_code}
  • Handle HTTP conditional request headers as in POST /entities/items/{item_id}/aliases/{language_code}
  • Handle user authentication/authorization like in POST /entities/items/{item_id}/aliases/{language_code}

Task breakdown notes:

  • Add the new route to OAS.
  • AddPropertyAliasesInLanguage happy path (including the edit summary)
    • directly use the AliasesDeserializer for deserialization
    • ETag and Last-Modified
    • include difference between 200 OK and 201 CREATED cases
  • Create use case validation/deserialization
  • 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/Add an alias in a given language for a property to Create/Add aliases in a given language for a property.Oct 11 2023, 12:24 PM
Ifrahkhanyaree_WMDE updated the task description. (Show Details)
Ifrahkhanyaree_WMDE set the point value for this task to 8.

@Ifrahkhanyaree_WMDE Should the key in the context of the invalid-property-id be property-id instead of property?

Jakob_WMDE renamed this task from Create/Add aliases in a given language for a property to ☃️ Create/Add aliases in a given language for a property.Nov 29 2023, 10:45 AM

Seems to work as intended. Thank you

Scenarios tested:

  • adding a single alias
  • adding multiple aliases
  • automated edit summaries
  • custom edit summary comment
  • authentication
  • HTTP conditional headers
  • errors
    • alias list is empty
    • empty alias
    • alias includes invalid characters
    • alias too long
    • duplicate alias
    • invalid MW edit tag
    • comment too long
    • invalid property ID, property does not exist, invalid language code