Skip to content

Commit d3a896d

Browse files
authored
Fix panic for module calls without source (#1950)
1 parent 0b06266 commit d3a896d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

terraform/loader.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ func (l *Loader) LoadConfig(dir string, callModuleType CallModuleType) (*Config,
9696
func (l *Loader) moduleWalkerFunc(walkLocal, walkRemote bool) ModuleWalkerFunc {
9797
return func(req *ModuleRequest) (*Module, *version.Version, hcl.Diagnostics) {
9898
switch source := req.SourceAddr.(type) {
99+
case nil:
100+
// Case for no source attribute. This is usually invalid, but is ignored to prevent panic.
101+
return nil, nil, nil
102+
99103
case addrs.ModuleSourceLocal:
100104
if !walkLocal {
101105
return nil, nil, nil

terraform/test-fixtures/v0.15.0_module/module.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ module "consul" {
77
source = "hashicorp/consul/aws"
88
version = "0.9.0"
99
}
10+
11+
module "no_source" {}

0 commit comments

Comments
 (0)