Error returned when fetching a list of tags with the last parameter on some tag names

We have recently used the List Repository Tags API to load the tags in the UI via GraphQL. @rchanila have observed that for some repositories, the pagination do not show correctly.

Sample Repository

Took a look and we can see that the URL for the 2nd page is:

https://gitlab.com/gitlab-org/gitlab/container_registry/3728789?after=0062048be81e0cd57f4743158add8c589fcfdfa3

Where after is the name of the last tag in the previous page.

Screenshot_2024-01-24_at_19.48.26

Changing the after param in the URL to the 2nd to the last tag in the first page, we get:

https://gitlab.com/gitlab-org/gitlab/container_registry/3728789?after=0062048be81

Which now loads tags successfully.

Looking at the request to the container registry:

https://log.gprd.gitlab.net/app/r/s/ukZgP

We get some errors on specific tag names such as 0062048be81e0cd57f4743158add8c589fcfdfa3 with a json.msg in the logs of finding tags detail with pagination: ERROR: invalid byte sequence for encoding "UTF8": 0xd3 0x4e (SQLSTATE 22021).