serverlessworkflow / synapse

Serverless Workflow Management System (WFMS)
https://serverlessworkflow.io
Apache License 2.0
231 stars 35 forks source link

JsonSerializationException: Error converting value "PT1M" to type 'System.Nullable`1[System.TimeSpan]'. Path 'actions[1].sleep.before' #346

Closed bvandewe closed 5 months ago

bvandewe commented 1 year ago

What happened:

With the current 0.4.0, when trying to force some delay on an action with sleep.after: PT1M, the UI/workflow editor doesnt accept the duration definition and throws the following error, even though the auto-complete knows about the "sleep" attribute.

action definition:

  ...
  "actions": [
    [
        {
          "name": "Do something",
          "functionRef": {
            "refName": "my-function",
            "arguments": {
              "foo": "${ .bar }"
            }
          },
          "sleep": {
              "before": "PT1M"
          }
        }
     ]
Newtonsoft.Json.JsonSerializationException: Error converting value "PT1M" to type 'System.Nullable`1[System.TimeSpan]'. Path 'actions[1].sleep.before', line 79, position 30.
blazor.webassembly.js:1  ---> System.ArgumentException: Could not cast or convert from System.String to System.TimeSpan.
blazor.webassembly.js:1    at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(Object value, Type initialType, Type targetType)
blazor.webassembly.js:1    at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue, CultureInfo culture, Type targetType)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
blazor.webassembly.js:1    Exception_EndOfInnerExceptionStack
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerProxy.PopulateInternal(JsonReader reader, Object target)
blazor.webassembly.js:1    at Newtonsoft.Json.JsonSerializer.Populate(JsonReader reader, Object target)
blazor.webassembly.js:1    at Newtonsoft.Json.AbstractClassConverter`1[[ServerlessWorkflow.Sdk.Models.StateDefinition, ServerlessWorkflow.Sdk, Version=0.8.4.0, Culture=neutral, PublicKeyToken=null]].ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
blazor.webassembly.js:1    at Newtonsoft.Json.AbstractClassConverterFactory.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
blazor.webassembly.js:1    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
blazor.webassembly.js:1    at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
blazor.webassembly.js:1    at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
blazor.webassembly.js:1    at Neuroglia.Serialization.NewtonsoftJsonSerializer.Deserialize(Stream input, Type returnType)
blazor.webassembly.js:1    at Neuroglia.Serialization.NewtonsoftJsonSerializer.<>c__DisplayClass12_0.<DeserializeAsync>b__0()
blazor.webassembly.js:1    at System.Threading.Tasks.Task`1[[System.Object, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InnerInvoke()
blazor.webassembly.js:1    at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object )
blazor.webassembly.js:1    at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread , ExecutionContext , ContextCallback , Object )
blazor.webassembly.js:1 --- End of stack trace from previous location ---
blazor.webassembly.js:1    at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread , ExecutionContext , ContextCallback , Object )
blazor.webassembly.js:1    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& , Thread )
blazor.webassembly.js:1 --- End of stack trace from previous location ---
blazor.webassembly.js:1    at Neuroglia.Serialization.NewtonsoftJsonSerializer.DeserializeAsync(Stream input, Type returnType, CancellationToken cancellationToken)
blazor.webassembly.js:1    at Neuroglia.Serialization.TextSerializerBase.DeserializeAsync(Byte[] input, Type returnType, CancellationToken cancellationToken)
blazor.webassembly.js:1    at Neuroglia.Serialization.TextSerializerBase.DeserializeAsync(String input, Type returnType, CancellationToken cancellationToken)
blazor.webassembly.js:1    at Neuroglia.Serialization.TextSerializerBase.<DeserializeAsync>d__29`1[[ServerlessWorkflow.Sdk.Models.WorkflowDefinition, ServerlessWorkflow.Sdk, Version=0.8.4.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
blazor.webassembly.js:1    at Synapse.Dashboard.Pages.Workflows.Editor.Effects.WorkflowEditorEffects.OnTextBasedEditorChange(HandleTextBasedEditorChange action, IEffectContext context)

What you expected to happen:

Ability to use the sleep.after or sleep.before with a duration expressed in ISO8601.

How to reproduce it:

See above

Anything else we need to know?: 0.4.0

Environment: K8s

cdavernas commented 5 months ago

Closed as fixed in #366: serialization is now System.Text.Json based and string-based durations have been dropped in favor of duration objects.