Skip to content

Unmet conditions not propagated when a guard prevents a transition #645

@Ninho67

Description

@Ninho67

We have recently done 2 things in our code base:

  • use FireAsync instead of Fire
  • moved from Stateless 5.16.0 to 5.20.1

Our unit tests suddenly started failing because the unmet conditions were not present in the StatelessTransitionException<,> exception anymore.
Rolling back to 5.17.0 works. Tests start failing in 5.18.0.

I haven't checked the code in details, but have noticed this in debug:

        private async Task InternalFireOneAsync(TTrigger trigger, params object[] args)
        {
            if (_triggerConfiguration.TryGetValue(trigger, out TriggerWithParameters configuration))
            {
                configuration.ValidateParameters(args);
            }

            var source = State;
            var representativeState = GetRepresentation(source);

            var foundHandler = await representativeState.TryFindHandlerAsync(trigger, args);

            if (foundHandler == null || foundHandler.UnmetGuardConditions.Any())
            {
                await _unhandledTriggerAction.ExecuteAsync(representativeState.UnderlyingState, trigger, null); // <|----
                return;
            }

In the code above, we're entering the last if condition with foundHandler not null but with 1 unmet guard. In the next line, null is passed for unmet guards. Could this be a bug ?

Thanks in advance for your answer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions