aws / aws-codedeploy-agent

Host Agent for AWS CodeDeploy
https://aws.amazon.com/codedeploy
Apache License 2.0
329 stars 187 forks source link

Source sequence is illegal/malformed utf-8 #284

Open ravimartins opened 3 years ago

ravimartins commented 3 years ago

Hello guys,

I'm getting the following error when I try to deploy to my EC2 Instances. I have others applications, with the same structure, that is working perfectly.

I got this on codedeploy-agent-log:

[Aws::CodeDeployCommand::Client 200 0.078138 0 retries] put_host_command_complete(command_status:"Failed",diagnostics:{format:"JSON",payload:"{\"error_code\":5,\"script_name\":\"\",\"message\":\"source sequence is illegal/malformed utf-8\",\"log\":\"\"}"}

Someone knows what is happening?

janusz-mw commented 3 years ago

I have the same issue. I'm using EC2 Windows machine.

I suspect that the error is caused by some diacritics in the file names, but didn't confirm that yet.

kedde commented 3 years ago

I had a similar issue running an ec2 instance where I had the danish letter 'ø' in one of the filenames

/aws-codedeploy-agent/lib/instance_agent/plugins/codedeploy/install_instruction.rb:169:in to_json': source sequence is illegal/malformed utf-8 (JSON::GeneratorError) from D:/git/aws-codedeploy-agent/lib/instance_agent/plugins/codedeploy/install_instruction.rb:169:into_json' from D:/git/aws-codedeploy-agent/lib/instance_agent/plugins/codedeploy/installer.rb:45:in block in install' from D:/git/aws-codedeploy-agent/lib/instance_agent/plugins/codedeploy/installer.rb:44:inopen' from D:/git/aws-codedeploy-agent/lib/instance_agent/plugins/codedeploy/installer.rb:44:in install' from D:/git/aws-codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:144:inblock in ' from D:/git/aws-codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:72:in execute_command' from D:/git/aws-codedeploy-agent/lib/aws/codedeploy/local/deployer.rb:86:inblock in execute_events' from D:/git/aws-codedeploy-agent/lib/aws/codedeploy/local/deployer.rb:85:in each' from D:/git/aws-codedeploy-agent/lib/aws/codedeploy/local/deployer.rb:85:inexecute_events' from D:/git/aws-codedeploy-agent/bin/codedeploy-local:129:in `

'

I found that encoding was set to IBM437

irb irb(main):001:0> ENCODING => #

To solve the problem I ticked this box image

irb irb(main):001:0> ENCODING => #

Maybe a possible solution to this in the code could be to force utf-8 encoding?

janusz-mw commented 3 years ago

@kedde thanks. Checking this box solves the issue.

MartinHeynAndersen commented 1 year ago

We have the same issue when trying to deploy our server package. Multiple files in the package is containg dainsh chars and we are unable to rename these files. We are deploying to a Windows server 2016 instance. The workaround with activating the feature "BETA: Use unicode UTF-8 for world wide language support" does not seem like a viable solution for us.

mwjones-aws commented 1 year ago

What is your operating system level locale setting?

MartinHeynAndersen commented 1 year ago

Hi Mike

The local of the target EC2 operating system is English(United States): image

I tried changing it to Danish but it did not seem to help.

t0shiii commented 1 year ago

@MartinHeynAndersen we will work on reproducing this issue and get back to you.

jeremy-caylent commented 1 year ago

Hi everyone,

So i ran into this issue recently.

The reason for the issue was some spanish characters in the application code. Try using the following command to search your application source repo to find any issues:

find . | perl -ne 'print if /[^[:ascii:]]/'

After updating those file names, it worked correctly.

I did use the windows language settings UTF fix temporally until the underlying fix was applied. This can be done via powershell like so:

Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Nls\CodePage" -Name "ACP" -Value '65001' -Type String
Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Nls\CodePage" -Name "OEMCP" -Value '65001' -Type String
Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Nls\CodePage" -Name "MACCP" -Value '65001' -Type String

reboot