Loading...
Loading...
### Terraform Version ```shell Terraform v1.15.3 on darwin_arm64 ``` ### Terraform Configuration Files ```terraform terraform { required_version = ">= 1.15" } variable "module_version" { type = string default = null const = true } variable "module_source" { type = string default = "./mymodule" const = true } module "my_module" { source = var.module_source version = var.module_version } resource "terraform_data" "data" { } ``` ### Debug Output ``` 2026-05-20T14:33:05.635-0500 [INFO] Terraform version: 1.15.3 2026-05-20T14:33:05.635-0500 [DEBUG] using github.com/hashicorp/go-tfe v1.105.0 2026-05-20T14:33:05.635-0500 [DEBUG] using github.com/hashicorp/hcl/v2 v2.24.0 2026-05-20T14:33:05.635-0500 [DEBUG] using github.com/hashicorp/terraform-svchost v0.2.1 2026-05-20T14:33:05.635-0500 [DEBUG] using github.com/zclconf/go-cty v1.18.0 2026-05-20T14:33:05.635-0500 [INFO] Go runtime version: go1.25.10 2026-05-20T14:33:05.635-0500 [INFO] CLI args: []string{"terraform", "init"} 2026-05-20T14:33:05.635-0500 [TRACE] Stdout is not a terminal 2026-05-20T14:33:05.635-0500 [TRACE] Stderr is a terminal of width 211 2026-05-20T14:33:05.635-0500 [TRACE] Stdin is a terminal 2026-05-20T14:33:05.635-0500 [DEBUG] Attempting to open CLI config file: /Users/e081470/.terraformrc 2026-05-20T14:33:05.635-0500 [DEBUG] File doesn't exist, but doesn't need to. Ignoring. 2026-05-20T14:33:05.635-0500 [DEBUG] checking for credentials in "/Users/e081470/.terraform.d/plugins" 2026-05-20T14:33:05.635-0500 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins 2026-05-20T14:33:05.635-0500 [DEBUG] will search for provider plugins in /Users/e081470/.terraform.d/plugins 2026-05-20T14:33:05.635-0500 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/e081470/fakeddi v0.1.0 for darwin_arm64 at /Users/e081470/.terraform.d/plugins/registry.terraform.io/e081470/fakeddi/0.1.0/darwin_arm64 2026-05-20T14:33:05.636-0500 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/e081470/fakeias v0.1.0 for darwin_arm64 at /Users/e081470/.terraform.d/plugins/registry.terraform.io/e081470/fakeias/0.1.0/darwin_arm64 2026-05-20T14:33:05.636-0500 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/e081470/fakenaas v0.1.0 for darwin_arm64 at /Users/e081470/.terraform.d/plugins/registry.terraform.io/e081470/fakenaas/0.1.0/darwin_arm64 2026-05-20T14:33:05.636-0500 [DEBUG] ignoring non-existing provider search directory /Users/e081470/Library/Application Support/io.terraform/plugins 2026-05-20T14:33:05.636-0500 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins 2026-05-20T14:33:05.636-0500 [INFO] CLI command args: []string{"init"} 2026-05-20T14:33:05.646-0500 [TRACE] ModuleInstaller: installing child modules for . into .terraform/modules 2026-05-20T14:33:05.646-0500 [TRACE] terraform.NewContext: starting 2026-05-20T14:33:05.646-0500 [TRACE] terraform.NewContext: complete 2026-05-20T14:33:05.646-0500 [TRACE] building graph for terraform dependencies 2026-05-20T14:33:05.646-0500 [TRACE] Executing graph transform *terraform.RootVariableTransformer 2026-05-20T14:33:05.647-0500 [TRACE] Executing graph transform *terraform.ModuleTransformer 2026-05-20T14:33:05.647-0500 [TRACE] ModuleTransformer: Added module.my_module as *terraform.nodeInstallModule 2026-05-20T14:33:05.647-0500 [TRACE] Executing graph transform *terraform.LocalTransformer 2026-05-20T14:33:05.647-0500 [TRACE] Executing graph transform *terraform.ReferenceTransformer 2026-05-20T14:33:05.647-0500 [DEBUG] ReferenceTransformer: "var.module_version" references: [] 2026-05-20T14:33:05.647-0500 [DEBUG] ReferenceTransformer: "var.module_source" references: [] 2026-05-20T14:33:05.647-0500 [DEBUG] ReferenceTransformer: "module.my_module" references: [var.module_source var.module_version] 2026-05-20T14:33:05.647-0500 [TRACE] Executing graph transform *terraform.TransformFilter 2026-05-20T14:33:05.647-0500 [TRACE] Executing graph transform *terraform.variableValidationTransformer 2026-05-20T14:33:05.647-0500 [TRACE] variableValidationTransformer: adding validation nodes for any existing variable evaluation nodes 2026-05-20T14:33:05.647-0500 [TRACE] variableValidationTransformer: var.module_version has no validation rules 2026-05-20T14:33:05.647-0500 [TRACE] variableValidationTransformer: var.module_source has no validation rules 2026-05-20T14:33:05.647-0500 [TRACE] Executing graph transform *terraform.RootTransformer 2026-05-20T14:33:05.647-0500 [TRACE] Executing graph transform *terraform.TransitiveReductionTransformer 2026-05-20T14:33:05.647-0500 [TRACE] Completed graph transform: module.my_module - *terraform.nodeInstallModule var.module_source - *terraform.NodeRootVariable var.module_version - *terraform.NodeRootVariable root - terraform.graphNodeRoot module.my_module - *terraform.nodeInstallModule var.module_source - *terraform.NodeRootVariable var.module_version - *terraform.NodeRootVariable ------ 2026-05-20T14:33:05.647-0500 [DEBUG] Starting graph walk: walkInit 2026-05-20T14:33:05.647-0500 [TRACE] vertex "var.module_source": starting visit (*terraform.NodeRootVariable) 2026-05-20T14:33:05.647-0500 [TRACE] vertex "var.module_source": belongs to 2026-05-20T14:33:05.647-0500 [TRACE] vertex "var.module_version": starting visit (*terraform.NodeRootVariable) 2026-05-20T14:33:05.647-0500 [TRACE] NodeRootVariable: evaluating var.module_source 2026-05-20T14:33:05.647-0500 [TRACE] vertex "var.module_version": belongs to 2026-05-20T14:33:05.647-0500 [TRACE] PrepareFinalInputVariableValue: preparing var.module_source 2026-05-20T14:33:05.647-0500 [TRACE] PrepareFinalInputVariableValue: var.module_source has a default value 2026-05-20T14:33:05.647-0500 [TRACE] PrepareFinalInputVariableValue: var.module_source has no defined value 2026-05-20T14:33:05.647-0500 [TRACE] vertex "var.module_source": visit complete 2026-05-20T14:33:05.647-0500 [TRACE] NodeRootVariable: evaluating var.module_version 2026-05-20T14:33:05.647-0500 [TRACE] PrepareFinalInputVariableValue: preparing var.module_version 2026-05-20T14:33:05.647-0500 [TRACE] PrepareFinalInputVariableValue: var.module_version has a default value 2026-05-20T14:33:05.647-0500 [TRACE] PrepareFinalInputVariableValue: var.module_version has no defined value 2026-05-20T14:33:05.647-0500 [TRACE] vertex "var.module_version": visit complete 2026-05-20T14:33:05.647-0500 [TRACE] vertex "module.my_module": starting visit (*terraform.nodeInstallModule) 2026-05-20T14:33:05.647-0500 [TRACE] vertex "module.my_module": belongs to 2026-05-20T14:33:05.648-0500 [ERROR] vertex "module.my_module" error: Invalid registry module source address 2026-05-20T14:33:05.648-0500 [TRACE] vertex "module.my_module": visit complete, with errors 2026-05-20T14:33:05.648-0500 [TRACE] dag/walk: upstream of "root" errored, so skipping ╷ │ Error: Invalid registry module source address │ │ on main.tf line 18, in module "my_module": │ 18: source = var.module_source │ │ Failed to parse module registry address: can't use local directory "./mymodule" as a module registry address. │ │ Terraform assumed that you intended a module registry source address because you also set the argument "version", which applies only to registry modules. ╵ ``` ### Expected Behavior When the `version` is evaluated to `null` I expected the `version` attribute to act as if it was not set. The [documentation for `null`](https://developer.hashicorp.com/terraform/language/expressions/types#null) _seems_ to imply this should be the case: > a value that represents absence or omission. If you set an argument of a resource to null, Terraform behaves as though you had completely omitted it — it will use the argument's default value if it has one, or raise an error if the argument is mandatory. So, in this case, if `version` is evaluated to `null` I'd expect to be able to set `source` to a non-registry value. ### Actual Behavior The actual behavior is that a `null` version constraint is [handled as a empty set constraint](https://github.com/hashicorp/terraform/blob/main/internal/terraform/node_module_install.go#L295-L299). This means that the version is treated as being set instead of omitted, which causes the `source` to be validated as a registry. ### Steps to Reproduce 1. `terraform init` ### Additional Context I am very excited about the new dynamic module source feature! I _think_ this is a bug in how the version constraint is handled specifically for modules (the empty set constraint comment makes sense in other things that take versions, like providers) but maybe it is an enhancement? The end goal of supporting this is both consistency with existing `null` behavior as well as the ability to make the `source` of a module flexible enough to point to different types of underlying systems. ### References _No response_ ### Generative AI / LLM assisted development? _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.