aws-codedeploy-agent icon indicating copy to clipboard operation
aws-codedeploy-agent copied to clipboard

Source sequence is illegal/malformed utf-8

Open ravimartins opened this issue 4 years ago • 8 comments

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?

ravimartins avatar May 21 '21 17:05 ravimartins

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.

janusz-mw avatar Jun 14 '21 13:06 janusz-mw

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:in to_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:in open' 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:in block in class:CommandExecutor' 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:in block 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:in execute_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 => #Encoding:IBM437

To solve the problem I ticked this box image

irb irb(main):001:0> ENCODING => #Encoding:UTF-8

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

kedde avatar Jun 23 '21 07:06 kedde

@kedde thanks. Checking this box solves the issue.

janusz-mw avatar Jul 05 '21 10:07 janusz-mw

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.

MartinHeynAndersen avatar Dec 13 '22 07:12 MartinHeynAndersen

What is your operating system level locale setting?

mwjones-aws avatar Dec 14 '22 22:12 mwjones-aws

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.

MartinHeynAndersen avatar Dec 15 '22 07:12 MartinHeynAndersen

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

t0shiii avatar Dec 21 '22 22:12 t0shiii

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

jeremy-caylent avatar May 09 '23 14:05 jeremy-caylent