Skip to content

Commit 0259dd6

Browse files
committed
decode during recovery (instead of getting it decoded from list workflows
1 parent 318bb8e commit 0259dd6

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

dbos/recovery.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package dbos
22

3-
import (
4-
"strings"
5-
)
6-
73
func recoverPendingWorkflows(ctx *dbosContext, executorIDs []string) ([]WorkflowHandle[any], error) {
84
workflowHandles := make([]WorkflowHandle[any], 0)
95
// List pending workflows for the executors
@@ -18,11 +14,21 @@ func recoverPendingWorkflows(ctx *dbosContext, executorIDs []string) ([]Workflow
1814
}
1915

2016
for _, workflow := range pendingWorkflows {
21-
if inputStr, ok := workflow.Input.(string); ok {
22-
if strings.Contains(inputStr, "Failed to decode") {
23-
ctx.logger.Warn("Skipping workflow recovery due to input decoding failure", "workflow_id", workflow.ID, "name", workflow.Name)
17+
// Deserialize the workflow input
18+
var decodedInput any
19+
if workflow.Input != nil {
20+
inputStr, ok := workflow.Input.(string)
21+
if !ok {
22+
ctx.logger.Warn("Skipping workflow recovery: input is not an encoded string", "workflow_id", workflow.ID, "name", workflow.Name, "input_type", workflow.Input)
2423
continue
2524
}
25+
if inputStr != "" {
26+
decodedInput, err = deserialize(&inputStr)
27+
if err != nil {
28+
ctx.logger.Warn("Skipping workflow recovery due to input decoding failure", "workflow_id", workflow.ID, "name", workflow.Name, "error", err)
29+
continue
30+
}
31+
}
2632
}
2733

2834
if workflow.QueueName != "" {
@@ -59,7 +65,7 @@ func recoverPendingWorkflows(ctx *dbosContext, executorIDs []string) ([]Workflow
5965
WithWorkflowID(workflow.ID),
6066
}
6167
// Create a workflow context from the executor context
62-
handle, err := registeredWorkflow.wrappedFunction(ctx, workflow.Input, opts...)
68+
handle, err := registeredWorkflow.wrappedFunction(ctx, decodedInput, opts...)
6369
if err != nil {
6470
return nil, err
6571
}

0 commit comments

Comments
 (0)