aws-codedeploy-agent
aws-codedeploy-agent copied to clipboard
Source sequence is illegal/malformed utf-8
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?
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.
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:inblock 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:ininstall' from D:/git/aws-codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:144:inblock in class:CommandExecutor' from D:/git/aws-codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_executor.rb:72:inexecute_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:ineach' 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 => #Encoding:IBM437
To solve the problem I ticked this box

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 thanks. Checking this box solves the issue.
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.
What is your operating system level locale setting?
Hi Mike
The local of the target EC2 operating system is English(United States):

I tried changing it to Danish but it did not seem to help.
@MartinHeynAndersen we will work on reproducing this issue and get back to you.
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