boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
674 stars 46 forks source link

set utf8 in case system is not configured with LANG=en_US.UTF-8 #245

Closed tongueroo closed 2 years ago

tongueroo commented 2 years ago

This is a 🐞 bug fix.

Summary

Edge case error when special characters from terraform output, 3rd party script output, or system not configure with LANG=en_US.UTF-8, and terraspace errors.

Note, this occurred on codebuild by chance, but couldn't reproduce. Here's a small test script that was able to somewhat reproduce the "ArgumentError: invalid byte sequence in US-ASCII" error.

utf8-test.rb

puts __ENCODING__.name
str = "Rüby"
str = str.encode("iso-8859-1")
# str = str.force_encoding('UTF-8')
p str.sub!(/.*\]:\s+/, ' ') # remove log info from line

Also useful https://nuclearsquid.com/writings/ruby-1-9-encodings/

How to Test

Run acceptance test pipeline

Version Changes

Patch