Skip to content

Terraform Module Registry: Investigate duplicate exception check behavior

Context

Terraform Module registry allows uploading a module that is a duplicate of an existing module in the registry.

There are edge cases that can be confusing. Some of these are possibly bugs. We need to investigate which are expected behavior (and hence, we should clarify the documentation to address the confusion) and which are bugs.

Observed behavior

  • (1) upload my-test-module/my-test-system version 0.0.1 to project A - error: Package version already exists.
  • (2) upload my-test-module/my-test-system version 0.0.1 to project B - error: A package with the same name already exists in the namespace
  • (3) upload upload my-test-module/my-test-system version 0.0.3 (note: different version) to project B - error: A package with the same name already exists in the namespace
  • (4) upload my-test-module/my-test-system version 0.0.2 to project A - result: package created
  • (5) Change exception regex to a blank string, then upload my-test-module/my-test-system version 0.0.3 to project A - result: package created

Possibly confusing behavior:

  • Version checking overrides duplicate rule - see item (1) above

We have Unless duplicates are allowed, the package name and version must be unique in the top-level namespace. in the documentation. If (1) is intended behavior, maybe we should change the documentation to Even when duplicates are allowed, the package name and version must be unique in the top-level namespace.

Possibly buggy behavior:

  • Duplicate rule is only applied on other projects - see items (3), (4) and (5) above. Even when Allow duplicates is disabled (duplicates forbidden), it is still possible to upload multiple my-test-module/my-test-system packages, as long as they have different versions. It doesn't matter whether or not the module name matches the exception regexp.

⏯️ Reproducing the issue

Setup

  • Have GDK ready with a PAT
  • Prepare two projects, project A and project B, both under the same group Z
  • Go to group Z -> Settings -> Package and registries. In the Duplicate Packages section, turn off "Allow duplicates" and type "test" in the Exceptions
  • Prepare a Terraform package. You can clone terraform-aws-lambda and tar cvzf <terraform-aws-lambda-folder> to prepare the tar file for upload.
  • Upload the tar file from the previous step to project A

Test proper

  • (1) Upload my-test-module/my-test-system version 0.0.1 to project A:
curl --fail-with-body --header "PRIVATE-TOKEN: <pat>" --upload-file terraform-aws-lambda.tar http://gdk.test:3000/api/v4/projects/<project-A-id>/packages/terraform/modules/my-test-module/my-test-system/0.0.1/file
  • (2) upload my-test-module/my-test-system version 0.0.1 to project B - same command as (1), change project ID
  • (3) upload upload my-test-module/my-test-system version 0.0.3 to project B
  • (4) upload my-test-module/my-test-system version 0.0.2 to project A
  • (5) Change exception regex to a blank string, then upload my-test-module/my-test-system version 0.0.3 to project A
Edited by Radamanthus Batnag