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

NullReferenceException after upgrading 3.4.0 -> 3.8.1

Open R4cOOn opened this issue 2 years ago • 5 comments

We upgraded our library from 3.4.0 to 3.8.1.
We use PostgreSQL 14 as our backend and had to do a "manual upgrade" of the DB because the EF version used by the library wasn't supported by the the version we had.

Now things work most of the time but we have cases where interacting with the workflows raises NullReferenceExceptions.
Looking at the code it happens in WorkflowActivity.Enrich(WorkflowStep workflowStep) at line 65:

      current.SetTag("workflow.step.type", (object) workflowStep.BodyType.Name);

our workflowStep.BodyType is null because we use StepBodyAsync (as described in https://workflow-core.readthedocs.io/en/stable/getting-started/) and not the WorkflowStep class.
We also see log entries like [11:17:09 WorkflowCore.Services.WorkflowExecutor DBG] Starting step null on workflow eca3fed6-42bf-4ec8-b21b-72261e995ed7 for the same reason.

I didn't see any release notes mentioning a breaking change.
Is this a bug or do we need to make some changes?

We also see some DbUpdateException because of ScheduledCommand unique index constraint failing.
Are these also expected?

Cheers.

R4cOOn avatar Mar 21 '23 11:03 R4cOOn

@danielgerlag any news on that one?

still throwing. Fix is easy - just put a question mark there.

Any idea why this happens? How should we write our steps to avoid this problem?

We inherit the StepBody or StepBodyAsync

qrzychu avatar Nov 07 '23 10:11 qrzychu

image

this happens for the EndStep class:

using System;
using WorkflowCore.Models;

namespace WorkflowCore.Primitives
{
    public class EndStep : WorkflowStep
    {
        public override Type BodyType => null;

        public override ExecutionPipelineDirective InitForExecution(
            WorkflowExecutorResult executorResult, 
            WorkflowDefinition defintion, 
            WorkflowInstance workflow, 
            ExecutionPointer executionPointer)
        {
            return ExecutionPipelineDirective.EndWorkflow;
        }
    }
}

which explicitly sets this property to null

qrzychu avatar Nov 08 '23 10:11 qrzychu

Thanks for discovering that. We should not set the BodyType to null in the EndStep, that would be the correct solution.

danielgerlag avatar Nov 08 '23 17:11 danielgerlag

Does anyone have any workarounds for this? Our build system needs the System.Linq.Dynamic.Core bump in v3.10 but our workflow no longer works after v3.6.2, when the open telemetry stuff was put in.

DavidPx avatar May 09 '24 18:05 DavidPx