From bd27bb5b985bf90166153c95a0cf533ed2c4739b Mon Sep 17 00:00:00 2001 From: rinor Date: Fri, 3 May 2024 13:15:11 +0000 Subject: [PATCH] chore: prevent panics on invalid state input --- pkg/engine/engine.go | 4 ++++ pkg/runner/runner.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index c3b9474e..0793f956 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -331,6 +331,10 @@ func (e *Engine) complete(ctx context.Context, state *State) (*Return, error) { } func (e *Engine) Continue(ctx Context, state *State, results ...CallResult) (*Return, error) { + if state == nil { + return nil, fmt.Errorf("invalid continue call, missing state") + } + var added bool state = &State{ diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index b9c0a103..67c3d652 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -479,6 +479,10 @@ func (r *Runner) resume(callCtx engine.Context, monitor Monitor, env []string, s return nil, fmt.Errorf("invalid state, resume should not have StartContinuation set to true") } + if state.Continuation == nil { + return nil, errors.New("invalid state, resume should have Continuation data") + } + progress, progressClose := streamProgress(&callCtx, monitor) defer progressClose()