-
-
Notifications
You must be signed in to change notification settings - Fork 656
Fix for SET NAMES utf8 causing an unknown encoding error #3551
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue whereby the "SET NAMES utf8;" command resulted in an unknown encoding error by addressing two issues: ensuring that the encoding "utf8mb3" is mapped in the EncodingToCharset map and preventing a failure when the encoding is not recognized.
- Updated lib/packets/resultset_header.js to only update connection.config.charsetNumber when a valid mapping exists.
- Added the "utf8mb3" mapping with charset code 192 in lib/constants/encoding_charset.js.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/packets/resultset_header.js | Conditional update to avoid setting an undefined charsetNumber in the config. |
| lib/constants/encoding_charset.js | Added mapping for "utf8mb3" to fix the unknown encoding error. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3551 +/- ##
=======================================
Coverage 89.08% 89.08%
=======================================
Files 86 86
Lines 13531 13538 +7
Branches 1569 1569
=======================================
+ Hits 12054 12061 +7
Misses 1477 1477
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@sidorares, we can perform manually an empty commit to force the release-please in a specific version, for example, by pushing directly to git commit --allow-empty -m "chore: release 3.14.1" -m "Release-As: 3.14.1"Note This fix is already available in canary version. |
|
Thanks @wellwelwel ! done - #3552 |
![snyk-io[bot]](https://badgen.net/badge/icon/snyk-io%5Bbot%5D/green?label=)  [<img width="16" alt="Powered by Pull Request Badge" src="https://user-images.githubusercontent.com/1393946/111216524-d2bb8e00-85d4-11eb-821b-ed4c00989c02.png">](https://pullrequestbadge.com/?utm_medium=github&utm_source=reisene&utm_campaign=badge_info)<!-- PR-BADGE: PLEASE DO NOT REMOVE THIS COMMENT -->  <h3>Snyk has created this PR to upgrade mysql2 from 3.14.1 to 3.14.2.</h3> :information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project. <hr/> - The recommended version is **2 versions** ahead of your current version. - The recommended version was released **a month ago**. #### Issues fixed by the recommended upgrade: | | Issue | Score | Exploit Maturity | :-------------------------:|:-------------------------|:-------------------------|:-------------------------  | Regular Expression Denial of Service (ReDoS)<br/>[SNYK-JS-BRACEEXPANSION-9789073](https://snyk.io/vuln/SNYK-JS-BRACEEXPANSION-9789073) | **57** | Proof of Concept  | Regular Expression Denial of Service (ReDoS)<br/>[SNYK-JS-BRACEEXPANSION-9789073](https://snyk.io/vuln/SNYK-JS-BRACEEXPANSION-9789073) | **57** | Proof of Concept <details> <summary><b>Release notes</b></summary> <br/> <details> <summary>Package name: <b>mysql2</b></summary> <ul> <li> <b>3.14.2</b> - <a href="https://redirect.github.com/sidorares/node-mysql2/releases/tag/v3.14.2">2025-07-10</a></br><h2><a href="https://redirect.github.com/sidorares/node-mysql2/compare/v3.14.1...v3.14.2">3.14.2</a> (2025-07-10)</h2> <h3>Bug Fixes</h3> <ul> <li>pass columnType to readDateTimeString (<a href="https://redirect.github.com/sidorares/node-mysql2/issues/3700" data-hovercard-type="pull_request" data-hovercard-url="/sidorares/node-mysql2/pull/3700/hovercard">#3700</a>) (<a href="https://redirect.github.com/sidorares/node-mysql2/commit/1ee48cce69eb7d89c52ac2c0369d28b324bb7848">1ee48cc</a>)</li> </ul> </li> <li> <b>3.14.2-canary.1ee48cce</b> - 2025-07-10 </li> <li> <b>3.14.1</b> - <a href="https://redirect.github.com/sidorares/node-mysql2/releases/tag/v3.14.1">2025-04-27</a></br><h2><a href="https://redirect.github.com/sidorares/node-mysql2/compare/v3.14.0...v3.14.1">3.14.1</a> (2025-04-27)</h2> <h3>Bug Fixes</h3> <ul> <li>Fix for SET NAMES utf8 causing an unknown encoding error (<a href="https://redirect.github.com/sidorares/node-mysql2/issues/3551" data-hovercard-type="pull_request" data-hovercard-url="/sidorares/node-mysql2/pull/3551/hovercard">#3551</a>) <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/sidorares/node-mysql2/commit/0617813d21cf9de5fcbd4dd283eafc6d090eeeaf/hovercard" href="https://redirect.github.com/sidorares/node-mysql2/commit/0617813d21cf9de5fcbd4dd283eafc6d090eeeaf"><tt>0617813</tt></a></li> </ul> </li> </ul> from <a href="https://redirect.github.com/sidorares/node-mysql2/releases">mysql2 GitHub release notes</a> </details> </details> --- > [!IMPORTANT] > > - Check the changes in this PR to ensure they won't cause issues with your project. > - This PR was automatically created by Snyk using the credentials of a real user. > - Max score is 1000. Note that the real score may have changed since the PR was raised. --- **Note:** _You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs._ **For more information:** <img src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiI3MDZkMzljMC1kMWZlLTQwMDItODZlNC02ZWVkNjIwNzVmYTEiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjcwNmQzOWMwLWQxZmUtNDAwMi04NmU0LTZlZWQ2MjA3NWZhMSJ9fQ==" width="0" height="0"/> > - 🧐 [View latest project report](https://app.snyk.io/org/reisene/project/55e114f8-489e-4f14-b900-20574b041e59?utm_source=github-cloud-app&utm_medium=referral&page=upgrade-pr) > - 📜 [Customise PR templates](https://docs.snyk.io/scan-using-snyk/pull-requests/snyk-fix-pull-or-merge-requests/customize-pr-templates?utm_source=&utm_content=fix-pr-template) > - 🛠 [Adjust upgrade PR settings](https://app.snyk.io/org/reisene/project/55e114f8-489e-4f14-b900-20574b041e59/settings/integration?utm_source=github-cloud-app&utm_medium=referral&page=upgrade-pr) > - 🔕 [Ignore this dependency or unsubscribe from future upgrade PRs](https://app.snyk.io/org/reisene/project/55e114f8-489e-4f14-b900-20574b041e59/settings/integration?pkg=mysql2&utm_source=github-cloud-app&utm_medium=referral&page=upgrade-pr#auto-dep-upgrades) [//]: # 'snyk:metadata:{"customTemplate":{"variablesUsed":[],"fieldsUsed":[]},"dependencies":[{"name":"mysql2","from":"3.14.1","to":"3.14.2"}],"env":"prod","hasFixes":true,"isBreakingChange":false,"isMajorUpgrade":false,"issuesToFix":["SNYK-JS-BRACEEXPANSION-9789073","SNYK-JS-BRACEEXPANSION-9789073"],"prId":"706d39c0-d1fe-4002-86e4-6eed62075fa1","prPublicId":"706d39c0-d1fe-4002-86e4-6eed62075fa1","packageManager":"npm","priorityScoreList":[57],"projectPublicId":"55e114f8-489e-4f14-b900-20574b041e59","projectUrl":"https://app.snyk.io/org/reisene/project/55e114f8-489e-4f14-b900-20574b041e59?utm_source=github-cloud-app&utm_medium=referral&page=upgrade-pr","prType":"upgrade","templateFieldSources":{"branchName":"default","commitMessage":"default","description":"default","title":"default"},"templateVariants":["priorityScore"],"type":"auto","upgrade":["SNYK-JS-BRACEEXPANSION-9789073","SNYK-JS-BRACEEXPANSION-9789073"],"upgradeInfo":{"versionsDiff":2,"publishedDate":"2025-07-10T21:51:19.380Z"},"vulns":["SNYK-JS-BRACEEXPANSION-9789073","SNYK-JS-BRACEEXPANSION-9789073"]}'
query("SET NAMES utf8;");command returns instruction from the server "please use utf8mb3 client character set"2 issues we had:
EncodingToCharsetmapundefinedto connection configcharsetNumber, and next command failsFixes #3338