Skip to content

Commit 24298b0

Browse files
committed
allow forking at a step larger than the workflow max number of steps. This will fallback to the latest step
1 parent 386849f commit 24298b0

File tree

2 files changed

+0
-46
lines changed

2 files changed

+0
-46
lines changed

dbos/client_test.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -711,41 +711,6 @@ func TestForkWorkflow(t *testing.T) {
711711
}
712712
})
713713

714-
t.Run("ForkWithInvalidStep", func(t *testing.T) {
715-
originalWorkflowID := "original-workflow-invalid-step"
716-
717-
// Create an original workflow first
718-
handle, err := Enqueue[string, string](clientCtx, GenericEnqueueOptions[string]{
719-
WorkflowName: "ParentWorkflow",
720-
QueueName: queue.Name,
721-
WorkflowID: originalWorkflowID,
722-
WorkflowInput: "test",
723-
ApplicationVersion: serverCtx.GetApplicationVersion(),
724-
})
725-
if err != nil {
726-
t.Fatalf("failed to enqueue original workflow: %v", err)
727-
}
728-
729-
// Wait for completion
730-
_, err = handle.GetResult()
731-
if err != nil {
732-
t.Fatalf("failed to get result from original workflow: %v", err)
733-
}
734-
735-
// Try to fork at step 999 (beyond workflow's actual steps)
736-
_, err = clientCtx.ForkWorkflow(clientCtx, ForkWorkflowInput{
737-
OriginalWorkflowID: originalWorkflowID,
738-
StartStep: 999,
739-
})
740-
if err == nil {
741-
t.Fatal("expected error when forking at step 999, but got none")
742-
}
743-
// Verify the error message
744-
if !strings.Contains(err.Error(), "exceeds workflow's maximum step") {
745-
t.Fatalf("expected error message to contain 'exceeds workflow's maximum step', got: %v", err)
746-
}
747-
})
748-
749714
// Verify all queue entries are cleaned up
750715
if !queueEntriesAreCleanedUp(serverCtx) {
751716
t.Fatal("expected queue entries to be cleaned up after fork workflow tests")

dbos/system_database.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -829,17 +829,6 @@ func (s *sysDB) forkWorkflow(ctx context.Context, input forkWorkflowDBInput) err
829829

830830
originalWorkflow := wfs[0]
831831

832-
// Validate that startStep doesn't exceed the workflow's actual steps
833-
maxStepQuery := `SELECT COALESCE(MAX(function_id), 0) FROM dbos.operation_outputs WHERE workflow_uuid = $1`
834-
var maxStepID int
835-
err = tx.QueryRow(ctx, maxStepQuery, input.originalWorkflowID).Scan(&maxStepID)
836-
if err != nil {
837-
return fmt.Errorf("failed to query max step ID: %w", err)
838-
}
839-
if input.startStep > maxStepID && maxStepID > 0 {
840-
return fmt.Errorf("startStep %d exceeds workflow's maximum step %d", input.startStep, maxStepID)
841-
}
842-
843832
// Determine the application version to use
844833
appVersion := originalWorkflow.ApplicationVersion
845834
if input.applicationVersion != "" {

0 commit comments

Comments
 (0)