As of 2022-04-11, when Wikibase REST API is asked for data of an item which is a redirect to another item, requests results in 500 HTTP response containing
`{"code":"unexpected-error","message":"Unexpected error"}`
Instead, the API should recognize the redirect, and point the client to the relevant resource.
BDD
GIVEN Q123 is a redirect to Q321
WHEN I make a GET request to /entities/items/Q123
THEN I receive 301 HTTP response from the API
AND `Location` header in the response includes the path (excluding host name etc) of the /entities/items/Q321 resource
AND response body is empty
GIVEN Q123 is a redirect to Q321
WHEN I make a GET request to /entities/items/Q123
AND provide _fields=labels parameter to only get labels of an item
THEN I receive 301 HTTP response from the API
AND `Location` header in the response includes the path (excluding host name etc) of the /entities/items/Q321 resource
AND the path in the response also includes `_fields=labels` parameter
AND response body is empty
Note:
- if a user has no permission to get item data, they should get unauthorized access error not a 301 response
- FWIW, passing all query paremeter to the Location header is okay from the point of view of that story
- for url/location generation that method might of relevance: https://github.com/wikimedia/mediawiki/blob/master/includes/Rest/Router.php#L267
Open question: what should happen with query parameters, are they included in the Location header in the response, or is the "raw" URL returned - @WMDE-leszek to define