Problem
When publishing a private module to the Terraform Enterprise (TFE) private module registry using the API without a VCS connection, the API call returns a 2xx OK status. However, the TFE UI displays a "Setup Failed" error for the module.
Navigating to the module's page shows the version status as "OK".
However, attempting to view the specific version results in a 500 Internal Server Error.
Cause
The issue occurs when the version attribute in the API payload payload.json includes a "v" prefix, which is not a valid semantic version string for the registry.
Example of an incorrect payload.
{
"data": {
"type": "registry-module-versions",
"attributes": {
"version": "v1.2.3"
}
}
}Terraform Enterprise expects a semantic version string without the prefix. The presence of the "v" causes a database error when TFE attempts to parse the version number, as seen in the tfe-registry-api logs.
ERROR: invalid input syntax for integer: "v0" (SQLSTATE 22P02)
[ERROR] Error loading module versions:
| {*multierror.Error 1 error occurred:
| * ERROR: invalid input syntax for integer: "v0" (SQLSTATE 22P02)Solutions
Solution 1: Correct the Version Payload and Republish the Module
To resolve this issue, you must remove the incorrectly published module, correct the API payload, and republish the module.
- Remove the failed module entirely from the Terraform Enterprise UI.
-
Correct the
payload.jsonfile by removing the "v" prefix from theversionattribute. The version string should conform to semantic versioning standards.Example of a corrected payload.
{ "data": { "type": "registry-module-versions", "attributes": { "version": "1.2.3" } } } - Republish the module using the corrected
payload.jsonfile.
Additional Information
- For more details on the API endpoint, refer to the documentation on how to Create a module with no VCS connection.
- A bug report has been filed to improve error handling for this scenario in future Terraform Enterprise releases.