Skip to content

Commit

Permalink
Fix panic for module calls without source (#1950)
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Jan 8, 2024
1 parent 0b06266 commit d3a896d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions terraform/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ func (l *Loader) LoadConfig(dir string, callModuleType CallModuleType) (*Config,
func (l *Loader) moduleWalkerFunc(walkLocal, walkRemote bool) ModuleWalkerFunc {
return func(req *ModuleRequest) (*Module, *version.Version, hcl.Diagnostics) {
switch source := req.SourceAddr.(type) {
case nil:
// Case for no source attribute. This is usually invalid, but is ignored to prevent panic.
return nil, nil, nil

case addrs.ModuleSourceLocal:
if !walkLocal {
return nil, nil, nil
Expand Down
2 changes: 2 additions & 0 deletions terraform/test-fixtures/v0.15.0_module/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ module "consul" {
source = "hashicorp/consul/aws"
version = "0.9.0"
}

module "no_source" {}

0 comments on commit d3a896d

Please sign in to comment.