Fix missing module source panic (#1888) (#1889)

Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
Christian Mesh 2024-08-05 12:33:12 -04:00 committed by GitHub
parent daa85bd203
commit 6832136f13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -1,3 +1,8 @@
## 1.8.1 (Unreleased)
BUG FIXES:
* Fixed crash when module source is not present ([#1888](https://github.com/opentofu/opentofu/pull/1888))
## 1.8.0
UPGRADE NOTES:

View File

@ -138,12 +138,15 @@ func buildChildModules(parent *Config, walker ModuleWalker) (map[string]*Config,
Name: call.Name,
Path: path,
SourceAddr: call.SourceAddr,
SourceAddrRange: call.Source.Range(),
VersionConstraint: call.Version,
Parent: parent,
CallRange: call.DeclRange,
Call: NewStaticModuleCall(path, call.Variables, parent.Root.Module.SourceDir, call.Workspace),
}
if call.Source != nil {
// Invalid modules sometimes have a nil source field which is handled through loadModule below
req.SourceAddrRange = call.Source.Range()
}
child, modDiags := loadModule(parent.Root, &req, walker)
diags = append(diags, modDiags...)
if child == nil {