Skip to content

Commit

Permalink
Merge pull request #1005 from nyaruka/resume_parent_fix
Browse files Browse the repository at this point in the history
Fix resuming a parent run when flow is missing
  • Loading branch information
rowanseymour authored Mar 17, 2021
2 parents 7c3b482 + ad180c9 commit bf99094
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions flows/engine/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (s *session) continueUntilWait(sprint flows.Sprint, currentRun flows.FlowRu
childRun := currentRun
currentRun = parentRun

// as long as we didn't error, we can try to resume it
// as long as we didn't fail, we can try to resume it
if childRun.Status() != flows.RunStatusFailed {
// if flow for this run is a missing asset, we have a problem
if currentRun.Flow() == nil {
Expand All @@ -349,7 +349,7 @@ func (s *session) continueUntilWait(sprint flows.Sprint, currentRun flows.FlowRu
failure(sprint, currentRun, step, errors.Wrapf(err, "can't resume run as node no longer exists"))
}
} else {
// if we did error then that needs to bubble back up through the run hierarchy
// if we did fail then that needs to bubble back up through the run hierarchy
step, _, _ := currentRun.PathLocation()
failure(sprint, currentRun, step, errors.Errorf("child run for flow '%s' ended in error, ending execution", childRun.Flow().UUID()))
}
Expand Down
5 changes: 4 additions & 1 deletion flows/runs/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ func (r *flowRun) PathLocation() (flows.Step, flows.Node, error) {
step := r.Path()[len(r.Path())-1]

// check that we still have a node for this step
node := r.Flow().GetNode(step.NodeUUID())
var node flows.Node
if r.Flow() != nil {
node = r.Flow().GetNode(step.NodeUUID())
}
if node == nil {
return nil, nil, errors.Errorf("run is located at a flow node that no longer exists")
}
Expand Down

0 comments on commit bf99094

Please sign in to comment.