opentofu / registry

The all-new opentofu.org registry!
https://search.opentofu.org
Apache License 2.0
321 stars 36 forks source link

tofo init cannot find module version with a suffix #1094

Open c-baumgartner opened 1 week ago

c-baumgartner commented 1 week ago

Thank you for reporting an issue.

Trying to use module Azure/avm-ptn-alz/azurerm I have a strange behavior. Without a version constraint it will always use version 0.8.1

Trying specifing the version manually to v0.9.0-beta2 will result in the following error:

╷
│ Error: Unresolvable module version constraint
│ 
│   on main.tf line 8:
│    8: module "alz_architecture" {
│ 
│ There is no available version of module "registry.opentofu.org/Azure/avm-ptn-alz/azurerm" (main.tf:8) which matches the given version constraint. The newest available version is 0.8.1.
╵

Looking into the azurerm.json in the module catalog the beta-versions are available (only an excerpt from the file):

{
  "versions": [
    {
      "version": "v0.9.0-beta2"
    },
    {
      "version": "v0.9.0-beta"
    },
    {
      "version": "v0.8.1"
    }]
}

OpenTofu Version

OpenTofu v1.8.2
on linux_amd64

OpenTofu Configuration Files

module "alz_architecture" {
  source  = "Azure/avm-ptn-alz/azurerm"
  version = "v0.9.0-beta"

  architecture_name  = "alz"
  parent_resource_id = data.azapi_client_config.current.tenant_id
  location           = local.location
}
ollevche commented 1 week ago

Hey @c-baumgartner thank you for the issue! I believe you shouldn't specify the v prefix in module version so version = "v0.9.0-beta" becomes version = "0.9.0-beta". However, I agree error message doesn't make it clear at all.

c-baumgartner commented 1 week ago

Hi @ollevche - thank you for pointing that out - fun fact: Using "v0.8.1" ist working without any issue. It only fails for the version with the "-beta" suffix. The versions in the azurerm.json file are using the "v" too :-) So yeah, really confusing. But without the "v" it is working also for the -beta version constraint....

ollevche commented 1 week ago

@c-baumgartner I agree, that's inconsistent. We will discuss this issue at the core team triage meeting and hopefully change the error message or parsing logic.