workflow-core icon indicating copy to clipboard operation
workflow-core copied to clipboard

Object reference not set to an instance of an object.

Open Yuval2612 opened this issue 3 years ago • 2 comments

Describe the bug I'm using WorkFlowCore with asp.net core, at the end of each workflow I see in the log 'fail: WorkflowCore.Services.BackgroundTasks.WorkflowConsumer[0]' I look into it and saw that somehow the function GetWorkflowInstance was called and the workflows are empty. this function is located in the class that uses IPersistenceProvider.

To Reproduce Create a flow from JSON

Expected behavior The null exception should not appear.

Additional context example of the error log: fail: WorkflowCore.Services.BackgroundTasks.WorkflowConsumer[0] Error executing item 41b5ef64-ba42-4511-8ccc-7b78d65adc80 - Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. at WorkflowCore.Services.BackgroundTasks.WorkflowConsumer.ProcessItem(String itemId, CancellationToken cancellationToken) at WorkflowCore.Services.BackgroundTasks.WorkflowConsumer.ProcessItem(String itemId, CancellationToken cancellationToken) at WorkflowCore.Services.BackgroundTasks.QueueConsumer.ExecuteItem(String itemId, EventWaitHandle waitHandle, Activity activity)

this is the JSON flow { "Id": "ny", "Version": 1, "DataType": "Getb.Evaluation.Flow.Manager.FlowExecution.FlowContext, Getb.Evaluation.Flow.Manager", "ErrorBehavior":"Terminate", "Steps": [ { "Id": "Initialization", "StepType": "Getb.Evaluation.Flow.Manager.Steps.Initialization, Getb.Evaluation.Flow.Manager", "ErrorBehavior":"Terminate", "NextStepId": "ParallelTracking" }, { "Id": "ParallelTracking", "StepType": "WorkflowCore.Primitives.Sequence, WorkflowCore", "ErrorBehavior":"Terminate", "NextStepId": "Evaluation", "Do": [ [ { "Id": "Tracking", "StepType": "Getb.Evaluation.Flow.Manager.Steps.Tracking, Getb.Evaluation.Flow.Manager", "ErrorBehavior":"Terminate", "Inputs": { "System": ""ny"", "IgnorePlots": ""py"" } } ] ] }, { "Id": "Evaluation", "StepType": "Retb.Evaluation.Flow.Manager.Steps.Evaluation, Retb.Evaluation.Flow.Manager", "ErrorBehavior":"Terminate", "NextStepId": "Finalization", "Inputs": { "System": ""ny"" } }, { "Id": "Finalization", "StepType": "Retb.Evaluation.Flow.Manager.Steps.Finalization, Retb.Evaluation.Flow.Manager", "ErrorBehavior":"Terminate" } ] }

Yuval2612 avatar Jul 20 '22 14:07 Yuval2612

This is usually caused by incorrect persistence, and sometimes the workflow ends after it is started. You should provide more detailed information. For example persistence code, database

scccboom avatar Aug 08 '22 11:08 scccboom

I've encountered a similar issue and it was caused because in some cases my implementation of IPersistenceProvider was returning null from GetWorkflowInstance(...)

eli-ilushin avatar Jun 08 '23 07:06 eli-ilushin