Encoding error while importing module in Terraform Enterprise
A couple of weeks back, I was having trouble importing a module in Terraform Enterprise. This error keeps popping up during publish:
Error: 1 error occurred: * pq: invalid byte sequence for encoding "UTF8": 0x00
Based on the error message and searching through the net, it points to an encoding error. Most results show that the error indicates PostgreSQL doesn’t accept non-UTF8. So my commit is pushing something that is not UTF8 encoded. I tried going through terraform enterprise container logs to find out more about this error but nothing helpful comes up.
I was puzzled by this since this version to be published only adds an auto-generated README.md
using terraform-docs
. There was already a previous version committed (also generated by terraform-docs) so this new version only adds the diff to that last commit. So my first instinct was to check if the diff added non-UTF8 chars but that doesn’t seem to be the case (after several hours of trial and error).
So at some point, I decided to check if the file is UTF8 encoded. Checking the previous commit using file *
in git bash, the README.md
file is UTF8 encoded. Now after generating a new version using terraform-docs, file encoding changed! All this time, I was running terraform-docs in VSCode terminal set as Powershell which has a different default encoding. So the solution for me was to change my default shell to git bash so encoding will be UTF8.