Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max char limit on short description with unicode fails #142

Closed
alexrashed opened this issue Apr 5, 2023 · 2 comments · Fixed by #143
Closed

max char limit on short description with unicode fails #142

alexrashed opened this issue Apr 5, 2023 · 2 comments · Fixed by #143

Comments

@alexrashed
Copy link

I just stumbled across a weird issue, where the action would suddenly fail (after quite a while not being executed at all).
After digging into the issue, it seems that the short-description limit is not correctly enforced.
The short-description input was introduced with 8fa8201, which already truncates inputs longer than 100 characters (since otherwise the API would return a status code 400 / Bad Request):

body['description'] = description.slice(0, DESCRIPTION_MAX_CHARS)

However, it seems that the limit differs when using supplementary characters like emojis. I did some tests, and it turns out that 1 supplementary character seems to be equal to 4 ASCII characters:

The run with 26 emojis results in the following error:

##[debug]Inputs: {
##[debug]  username: '***',
##[debug]  password: '***',
##[debug]  repository: '***/dockerhub-description-tests',
##[debug]  shortDescription: '💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻💻',
##[debug]  readmeFilepath: './README.md',
##[debug]  enableUrlCompletion: false,
##[debug]  imageExtensions: 'bmp,gif,jpg,jpeg,png,svg,webp'
##[debug]}
Reading description source file
##[debug]💻
Acquiring token
::add-mask::***
Sending PATCH request
##[debug]Error: Bad Request
##[debug]    at /home/runner/work/_actions/peter-evans/dockerhub-description/v3/dist/index.js:83:23
##[debug]    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Error: Bad Request
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Docker Hub Description

This could be explained by UTF-8 being a variable-length content-encoding where code-points with lower numerical values are using fewer bytes. This would basically mean that the limit of 100 is actually a limit of 100 bytes, not 100 characters.

@peter-evans
Copy link
Owner

Hi @alexrashed

Thank you for your detailed report of this issue. It would not surprise me that it should be 100 bytes, not 100 characters. The readme content already works this way and I truncate to a byte limit while respecting unicode surrogate pairs. I just need to add that functionality to the short-description, too, it seems. I'll make a fix for this soon.

@peter-evans
Copy link
Owner

Released a fix to truncate the short description in v3.4.0 / v3.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants