don't persist a nil state from Apply
Apply should not return a nil state to be persisted.
This commit is contained in:
parent
58e001c22a
commit
8c4031ef15
|
@ -168,6 +168,14 @@ func (b *Local) opApply(
|
|||
}
|
||||
diags = diags.Append(applyDiags)
|
||||
|
||||
// Even on error with an empty state, the state value should not be nil.
|
||||
// Return early here to prevent corrupting any existing state.
|
||||
if diags.HasErrors() && applyState == nil {
|
||||
log.Printf("[ERROR] backend/local: apply returned nil state")
|
||||
op.ReportResult(runningOp, diags)
|
||||
return
|
||||
}
|
||||
|
||||
// Store the final state
|
||||
runningOp.State = applyState
|
||||
err := statemgr.WriteAndPersist(opState, applyState)
|
||||
|
|
Loading…
Reference in New Issue