fix: Prevent nil panic in marshalProviderConfigs when inSingleModuleMode (#3294)

Signed-off-by: James Humphries <james@james-humphries.co.uk>
This commit is contained in:
James Humphries
2025-09-22 13:40:48 +01:00
committed by GitHub
parent 0a811e463d
commit 1e8ccb8d96

View File

@@ -290,6 +290,16 @@ func marshalProviderConfigs(
m[key] = p
}
// If we have gotten here from calling [MarshalSingleModule], then
// we do not recurse into child modules, because they are not
// available in that mode. In this mode c.Children will be nil and
// this means that we do not have the ability to get the provider_configs for
// the child modules.
// See the doc comment for [MarshalSingleModule] for more information.
if inSingleModuleMode(schemas) {
return
}
// Must also visit our child modules, recursively.
for name, mc := range c.Module.ModuleCalls {
// Keys in c.Children are guaranteed to match those in c.Module.ModuleCalls
@@ -323,11 +333,7 @@ func marshalProviderConfigs(
// Finally, marshal any other provider configs within the called module.
// It is safe to do this last because it is invalid to configure a
// provider which has passed provider configs in the module call.
// We don't recurse in single-module mode, because cc will be nil in
// that case.
if !inSingleModuleMode(schemas) {
marshalProviderConfigs(cc, schemas, m)
}
marshalProviderConfigs(cc, schemas, m)
}
}