Problem
When creating modules or publishing new module versions in Terraform Enterprise, a situation may occur that results in the module failing to publish with the error message commit unexpectedly resulted in rollback. This message is floated up from the PostgreSQL database.
Cause
To confirm this issue, investigate the logs from the ptfe_registry_worker. Positive confirmation shows the following error:
/home/circleci/terraform-registry/ingress/push/ingress_version.go:239 ERROR: invalid byte sequence for encoding "UTF8": 0x00 (SQLSTATE 22021)
followed by the SQL statement, which will likely show the README file of the module's repository with a NULL character between each original character. Different editors will show NULL characters differently.
This is caused when README files are UTF-16 encoded. Terraform Enterprise versions prior to v202201-2 don't handle UTF-16 encoded README files.
Solution
Short Term
As a stop-gap until the Terraform Enterprise version can be upgraded, you can convert the README to UTF-8 with the following commands depending on available options:
- Linux
iconv -f utf-16le -t utf-8 README.md -o README-UTF8.md && mv README-UTF8.md README.md - Powershell
Get-Content README.md | Set-Content -Encoding utf8 README-UTF8.txt ; Move-Item -Path README-UTF8.md -Destination README.md - VSCode
In the bottom right side of the footer there is an encoding button that can be clicked to change encoding: vscode.png
Long Term
Update Terraform Enterprise to v202201-2 or later.