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

Encoding::UndefinedConversionError #92

Open
ktimothy opened this issue Aug 26, 2021 · 4 comments
Open

Encoding::UndefinedConversionError #92

ktimothy opened this issue Aug 26, 2021 · 4 comments

Comments

@ktimothy
Copy link

ktimothy commented Aug 26, 2021

My test suite fails with error when trying to encode hostname:

.../rspec_junit_formatter-0.4.1/lib/rspec_junit_formatter.rb:173:in `encode': "\\xE2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
irb(main):003:0> Socket.gethostname
=> "timofei.kovalev\xE2\x80\x99s-MacBook-Pro"
irb(main):004:0> Socket.gethostname.encoding
=> #<Encoding:ASCII-8BIT>
@sj26
Copy link
Owner

sj26 commented Aug 26, 2021

Yes, it looks like your hostname is indeed invalidly encoded?

@ktimothy
Copy link
Author

ktimothy commented Aug 27, 2021

Yep, this is definitely a "think different" stuff, and I have changed it, but I still think the formatter should not fail in such cases.

@lewisf
Copy link

lewisf commented Sep 13, 2022

Ran into this issue today but with a different character

Encoding::UndefinedConversionError: "\x91" from ASCII-8BIT to UTF-8

\x91 or \u2018 which is LEFT SINGLE QUOTATION MARK. Any chance we can add a replacement to replace this to &apos; or is that not okay?

@lewisf
Copy link

lewisf commented Sep 14, 2022

Okay I discovered the issue -- we had test failure that spit out the following.

1) SomeTest when something happens

     Failure/Error: 
       expect(
         a_request(:get, "#{My::TestClient::HOST}/somepath?someparam=testparam"),
       ).to have_been_made.at_least_once
       The request GET http://localhost:9000/somepath?someparam=testparam was expected to execute at least 1 time but it executed 0 times
       The following requests were made:
       POST http://obfuscated:8126/obfuscatedwith body '????start????`???
??G????name?rspec.example?service?' with headers {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', ...} was made 1 time

The string seems to be recognized as ASCII-8BIT when it is actually UTF8? I don't think I fully understand how encodings work but why does Ruby think the encoding here is ASCII-8BIT?

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

No branches or pull requests

3 participants