Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException after upgrading 3.4.0 -> 3.8.1 #1155

Open
R4cOOn opened this issue Mar 21, 2023 · 4 comments
Open

NullReferenceException after upgrading 3.4.0 -> 3.8.1 #1155

R4cOOn opened this issue Mar 21, 2023 · 4 comments

Comments

@R4cOOn
Copy link

R4cOOn commented Mar 21, 2023

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.

@qrzychu
Copy link

qrzychu commented Nov 7, 2023

@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 pushed a commit to qrzychu/workflow-core that referenced this issue Nov 7, 2023
@qrzychu
Copy link

qrzychu commented Nov 8, 2023

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

@danielgerlag
Copy link
Owner

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

@DavidPx
Copy link

DavidPx commented May 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants