@@ -392,24 +392,28 @@ func RegisterWorkflow[P any, R any](ctx DBOSContext, fn GenericWorkflowFunc[P, R
392392
393393 // Register a type-erased version of the durable workflow for recovery
394394 typedErasedWorkflow := WorkflowFunc (func (ctx DBOSContext , input any ) (any , error ) {
395- // This type check is redundant with the one in the wrapper, but I'd better be safe than sorry
396395 typedInput , ok := input .(P )
397396 if ! ok {
398- // FIXME: we need to record the error in the database here
397+ wfID , err := ctx .GetWorkflowID ()
398+ if err != nil {
399+ return nil , fmt .Errorf ("failed to get workflow ID: %w" , err )
400+ }
401+ err = ctx .(* dbosContext ).systemDB .updateWorkflowOutcome (WithoutCancel (ctx ), updateWorkflowOutcomeDBInput {
402+ workflowID : wfID ,
403+ status : WorkflowStatusError ,
404+ err : newWorkflowUnexpectedInputType (fqn , fmt .Sprintf ("%T" , typedInput ), fmt .Sprintf ("%T" , input )),
405+ })
406+ if err != nil {
407+ return nil , fmt .Errorf ("failed to record unexpected input type error: %w" , err )
408+ }
399409 return nil , newWorkflowUnexpectedInputType (fqn , fmt .Sprintf ("%T" , typedInput ), fmt .Sprintf ("%T" , input ))
400410 }
401411 return fn (ctx , typedInput )
402412 })
403413
404414 typeErasedWrapper := WrappedWorkflowFunc (func (ctx DBOSContext , input any , opts ... WorkflowOption ) (WorkflowHandle [any ], error ) {
405- typedInput , ok := input .(P )
406- if ! ok {
407- // FIXME: we need to record the error in the database here
408- return nil , newWorkflowUnexpectedInputType (fqn , fmt .Sprintf ("%T" , typedInput ), fmt .Sprintf ("%T" , input ))
409- }
410-
411415 opts = append (opts , withWorkflowName (fqn )) // Append the name so ctx.RunAsWorkflow can look it up from the registry to apply registration-time options
412- handle , err := ctx .RunAsWorkflow (ctx , typedErasedWorkflow , typedInput , opts ... )
416+ handle , err := ctx .RunAsWorkflow (ctx , typedErasedWorkflow , input , opts ... )
413417 if err != nil {
414418 return nil , err
415419 }
0 commit comments