Skip to content

Commit 3c96821

Browse files
committed
chore: fix nil ptr deref on terraform plan data
1 parent a737d47 commit 3c96821

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

plan.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ func planJSONHook(dfs fs.FS, input Input) (func(ctx *tfcontext.Context, blocks t
8181
// priorPlanModule returns the state data of the module a given block is in.
8282
func priorPlanModule(plan *tfjson.Plan, block *terraform.Block) *tfjson.StateModule {
8383
if !block.InModule() {
84-
return plan.PriorState.Values.RootModule
84+
// If the block is not in a module, then we can just return the root module.
85+
if plan.PriorState != nil && plan.PriorState.Values != nil {
86+
return plan.PriorState.Values.RootModule
87+
}
88+
return nil
8589
}
8690

8791
var modPath []string

0 commit comments

Comments
 (0)