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

Fix Encoding::UndefinedConversionError in activation.rb #3214

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mckeed
Copy link
Contributor

@mckeed mckeed commented Feb 19, 2025

Motivation

Another fix for #3200. The last one only checked for malformed UTF-8, not correct UTF-8 with ASCII encoding, which is the issue.

Implementation

I changed it so it converts everything to UTF-8 to avoid the Encoding::UndefinedConversionError error.

Automated Tests

I updated the test so it fails on the previous fix.

Manual Tests

On macOS, add a unicode character to your system shell prompt and launch vscode using the .app, not from the command line.

@mckeed mckeed requested a review from a team as a code owner February 19, 2025 17:31
Copy link

graphite-app bot commented Feb 19, 2025

How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@webmatze
Copy link

@mckeed I tested the change on my system, and the problem is now solved, at least for me!

@@ -1,3 +1,3 @@
env = ENV.filter_map { |k, v| "#{k}RUBY_LSP_VS#{v}" if v.dup.force_encoding(Encoding::UTF_8).valid_encoding? }
env = ENV.filter_map { |k, v| v = v.dup.force_encoding(Encoding::UTF_8); "#{k}RUBY_LSP_VS#{v}" if v.valid_encoding? }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) Let's split this to make a it a little more readable:

Suggested change
env = ENV.filter_map { |k, v| v = v.dup.force_encoding(Encoding::UTF_8); "#{k}RUBY_LSP_VS#{v}" if v.valid_encoding? }
env = ENV.filter_map do |k, v|
v = v.dup.force_encoding(Encoding::UTF_8)
"#{k}RUBY_LSP_VS#{v}" if v.valid_encoding?
end

@andyw8 andyw8 added bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants