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

Incompatible character encodings: UTF-8 and ASCII-8BIT while crawling a page which contains UTF Characters. #146

Closed
starx opened this issue Sep 7, 2017 · 6 comments · Fixed by inspec/inspec#3376
Labels
Type: Bug Doesn't work as expected.

Comments

@starx
Copy link

starx commented Sep 7, 2017

Description

In a test, trying to verify contents of a web address by crawling is failing.

------Exception-------
Class: Kitchen::ActionFailed
Message: 1 actions failed.
Failed to complete #verify action: [incompatible character encodings: UTF-8 and ASCII-8BIT] on default-ubuntu-1604

Kitchen Log

InSpec and Platform Version

Inspec: 1.31.1
Kitchen: 1.16.0

Replication Case

A simple test case like this is enough. The page it is crawling should have Unicode characters. e.g. http://blog.mrnepal.com

describe command 'curl http://test.com' do
  its('stdout') { should match(/test_match/) }
end

I opened this issue previously in chef/inspec was instructed that issue was not related to Inspec but this repo instead.

@pratik705
Copy link

Hi,
I am hitting the exact issue on my test setup. any workaround/solution for the issue?

@lindhor
Copy link

lindhor commented Jul 3, 2018

Same for me in 1.43.5 and 2.2.27.

@lehn-etracker
Copy link

@pratik705 you can force message to be converted into UTF-8 by changing your local inspec reporter. Add .force_encoding(Encoding::UTF_8) within format_message method call like this:

lib/inspec/reporters/cli.rb:

format_message(
         color: impact,
         indicator: impact,
         indentation: 5,
         message: message.force_encoding(Encoding::UTF_8),
)

Btw: you will find the full path to cli.rb within trace message from your inspec call.

@greeneg
Copy link

greeneg commented Aug 25, 2018

I can confirm that @lehn-etracker 's fix resolves this when doing a kitchen verify on older Linux versions that use non-UTF8 encodings.

@chris-rock
Copy link
Collaborator

Thank you @starx for reporting the issue. I added a PR in InSpec to add a functional test to verify that this does not happen again. Once merged you need to update to latest inspec to prevent the issue happening.

@starx
Copy link
Author

starx commented Sep 10, 2018

@chris-rock That is Great news.

@tas50 tas50 added Type: Bug Doesn't work as expected. and removed bug labels Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Doesn't work as expected.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants