opentofu: `tofu init` cannot find module version with a "v" prefix

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
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (18 by maintainers)

Most upvoted comments

to make sure that we don’t accidentally change any behavior beyond what we’re actually intending to change. Therefore unfortunately I think, despite our best efforts to try for something more elegant, we should probably aim for a very narrow solution that minimizes the risk of any behavior changes other than the narrow case we’re trying to solve.

Couldn’t agree more.

I like the idea of leveraging the the upstream regex to just get rid of the prefixes. I think it’s safe to do so because at that point in the code we’re sure that the constraint is parseable with the old library. I went ahead and implemented the solution you describe above, and tests are passing.

There’s a caveat around the ruby-style parsing inconsistency, left a comment for you in the PR. I’d appreciate a review whenever you have the chance.

Hey @c-baumgartner we moved this issue as this is a bug in OpenTofu itself and this issue is now open for community contributions.

@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.

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.