Skip to content

Fix encoding changes when truncating PR descriptions#8077

Merged
deivid-rodriguez merged 1 commit intodependabot:mainfrom
mburumaxwell:pr-desc-truncate-fix
Nov 28, 2023
Merged

Fix encoding changes when truncating PR descriptions#8077
deivid-rodriguez merged 1 commit intodependabot:mainfrom
mburumaxwell:pr-desc-truncate-fix

Conversation

@mburumaxwell
Copy link
Copy Markdown
Contributor

This is a recreation of #7140 but with changes from #7487 and simpler tests.

When truncating the PR descriptions for Azure, the string is converted from UTF-8 to UTF-16, operated on then changed back to UTF-8. The last step fails resulting in a string with an invalid string that cannot be converted to JSON for the request body and the PR cannot be created.

This PR changes from force_encoding(...) to encode(...) which seems to solve the problem.
The spec I have added fails when using force_encoding(..) but works with encode(...) as guided by some Stack Overflow post. The issue shows up when converting to JSON using to_json so the spec is modified to test exactly that.

This should fix mburumaxwell/paklo#730

@mburumaxwell
Copy link
Copy Markdown
Contributor Author

@jurre when can this be merged?

@JensSchadron
Copy link
Copy Markdown

@jurre Out of curiosity, is there anything blocking this PR?

@mburumaxwell
Copy link
Copy Markdown
Contributor Author

@deivid-rodriguez could you have a look here?

@deivid-rodriguez deivid-rodriguez enabled auto-merge (squash) November 28, 2023 16:04
@deivid-rodriguez deivid-rodriguez merged commit b0de08b into dependabot:main Nov 28, 2023
@mburumaxwell
Copy link
Copy Markdown
Contributor Author

Thanks @deivid-rodriguez

@deivid-rodriguez
Copy link
Copy Markdown
Contributor

No problem!

@mburumaxwell mburumaxwell deleted the pr-desc-truncate-fix branch December 11, 2023 12:41
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 this pull request may close these issues.

source sequence is illegal/malformed utf-8

4 participants