elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.5k stars 1.2k forks source link

Incomplete signal received activity breaks app startup #1375

Closed matt4446 closed 3 years ago

matt4446 commented 3 years ago

During startup:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Elsa.Activities.Signaling.SignalReceivedBookmarkProvider.GetBookmarksInternalAsync(BookmarkProviderContext`1 context, CancellationToken cancellationToken)+MoveNext()
   at Elsa.Activities.Signaling.SignalReceivedBookmarkProvider.GetBookmarksInternalAsync(BookmarkProviderContext`1 context, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at System.Linq.AsyncEnumerable.<ToListAsync>g__Core|620_0[TSource](IAsyncEnumerable`1 source, CancellationToken cancellationToken) in /_/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs:line 36
   at System.Linq.AsyncEnumerable.<ToListAsync>g__Core|620_0[TSource](IAsyncEnumerable`1 source, CancellationToken cancellationToken) in /_/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs:line 36
   at Elsa.Activities.Signaling.SignalReceivedBookmarkProvider.GetBookmarksAsync(BookmarkProviderContext`1 context, CancellationToken cancellationToken)
   at Elsa.Services.BookmarkProvider`2.Elsa.Services.IBookmarkProvider.GetBookmarksAsync(BookmarkProviderContext context, CancellationToken cancellationToken)
   at Elsa.Services.Triggers.TriggersForActivityBlueprintAndWorkflowProvider.GetTriggersForBookmarkProvider(IBookmarkProvider provider, BookmarkProviderContext context, IActivityBlueprint activityBlueprint, IWorkflowBlueprint workflowBlueprint, CancellationToken cancellationToken)
   at Elsa.Services.Triggers.TriggersForActivityBlueprintAndWorkflowProvider.GetTriggersForActivityBlueprintAsync(IActivityBlueprint activityBlueprint, WorkflowExecutionContext workflowExecutionContext, IDictionary`2 activityTypes, CancellationToken cancellationToken)
   at Elsa.Services.Triggers.TriggersForBlueprintsProvider.<>c__DisplayClass6_0.<<GetWorkflowTriggersForWorkflowBlueprintAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Elsa.Services.Triggers.TriggersForBlueprintsProvider.GetWorkflowTriggersForWorkflowBlueprintAsync(IWorkflowBlueprint workflowBlueprint, IDictionary`2 activityTypes, CancellationToken cancellationToken)
   at Elsa.Services.Triggers.TriggersForBlueprintsProvider.GetTriggersAsync(IEnumerable`1 workflowBlueprints, CancellationToken cancellationToken)
   at Elsa.Services.Triggers.TriggerIndexer.IndexTriggersAsync(IEnumerable`1 workflowBlueprints, CancellationToken cancellationToken)
   at Elsa.Services.Triggers.TriggerIndexer.IndexTriggersAsync(CancellationToken cancellationToken)
   at Elsa.StartupTasks.IndexTriggers.ExecuteAsync(CancellationToken cancellationToken)
   at Elsa.Runtime.StartupRunner.StartupAsync(CancellationToken cancellationToken)
   at Elsa.HostedServices.StartupRunnerHostedService.StartAsync(CancellationToken cancellationToken)

Reproduction steps... once I work out how I broke it first.

  1. Create a workflow from the designer.
  2. Add signal received activity
  3. neglect everything it shows you and press save
  4. Save and publish
  5. Restart the site

This adds in an activity that looks something like:

{
          "$id": "5",
          "$type": "Elsa.Models.ActivityDefinitionProperty, Elsa.Abstractions",
          "Name": "Signal",
          "Expressions": {
            "$id": "6",
            "$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.String, System.Private.CoreLib]], System.Private.CoreLib",
          }
        }

Just adding a blank (empty string) literal value in fixes it. eg:

{
  "$id": "1",
  "$type": "Elsa.Persistence.YesSql.Documents.WorkflowDefinitionDocument, Elsa.Persistence.YesSql",
  "DefinitionId": "681c7d3a2d524598bf60813f5783f821",
  "DefinitionVersionId": "fd437b13d0094501a20f668dce39a295",
  "Version": 1,
  "Variables": {
    "$id": "2",
    "$type": "Elsa.Models.Variables, Elsa.Abstractions",
    "Data": {
      "$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib"
    }
  },
  "CustomAttributes": {
    "$id": "3",
    "$type": "Elsa.Models.Variables, Elsa.Abstractions",
    "Data": {
      "$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib"
    }
  },
  "IsSingleton": false,
  "PersistenceBehavior": "WorkflowBurst",
  "DeleteCompletedInstances": false,
  "IsPublished": true,
  "IsLatest": true,
  "Activities": [
    {
      "$id": "4",
      "$type": "Elsa.Models.ActivityDefinition, Elsa.Abstractions",
      "ActivityId": "60f7ca9f-c9ab-4250-8008-928595444966",
      "Type": "SignalReceived",
      "DisplayName": "Signal Received",
      "PersistWorkflow": false,
      "LoadWorkflowContext": false,
      "SaveWorkflowContext": false,
      "Properties": [
        {
          "$id": "5",
          "$type": "Elsa.Models.ActivityDefinitionProperty, Elsa.Abstractions",
          "Name": "Signal",
          "Expressions": {
            "$id": "6",
            "$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.String, System.Private.CoreLib]], System.Private.CoreLib",
            "Literal": ""
          }
        }
      ],
      "PropertyStorageProviders": {
        "$type": "System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.String, System.Private.CoreLib]], System.Private.CoreLib"
      }
    }
  ],
  "Connections": [],
  "Id": 191
}
sfmskywalker commented 3 years ago

Nice one.