From a22d91b65bc4172c27013f22a5c376ad2573cff7 Mon Sep 17 00:00:00 2001 From: Daniel Banck Date: Wed, 20 May 2026 18:33:15 +0200 Subject: [PATCH] terraform: Handle missing source in nodeInstallModule --- internal/terraform/node_module_install.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/terraform/node_module_install.go b/internal/terraform/node_module_install.go index 49a390df15..0fd64619e4 100644 --- a/internal/terraform/node_module_install.go +++ b/internal/terraform/node_module_install.go @@ -73,6 +73,12 @@ func (n *nodeInstallModule) References() []*addrs.Reference { func (n *nodeInstallModule) Execute(ctx EvalContext, walkOp walkOperation) tfdiags.Diagnostics { var diags tfdiags.Diagnostics + if n.ModuleCall.SourceExpr == nil { + // Cannot install a module without a source + // Outer diags should already contain a parsing error + return diags + } + var version configs.VersionConstraint hasVersion := false if n.ModuleCall.VersionExpr != nil { @@ -141,6 +147,12 @@ func (n *nodeInstallModule) DynamicExpand(ctx EvalContext) (*Graph, tfdiags.Diag var g Graph var diags tfdiags.Diagnostics + if n.Config == nil { + // Cannot expand without a config. This can happen when something goes wrong + // during module installation/Execute() above. + return nil, diags + } + expander := ctx.InstanceExpander() _, call := n.Addr.Call() expander.SetModuleSingle(n.Path(), call)