You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a simple orchestration and activity, which I've attached, that passes a TimeSpan parameter. The orchestration is able to deserialize the value, but the activity throws an error:
[2023-09-25T19:08:33.116Z] Function 'EchoTimeSpanAsync', Invocation id '53fbfc18-c746-4d37-9fe6-723d025830bc': An exception was thrown by the invocation.
[2023-09-25T19:08:33.117Z] Result: Function 'EchoTimeSpanAsync', Invocation id '53fbfc18-c746-4d37-9fe6-723d025830bc': An exception was thrown by the invocation.
Exception: Microsoft.Azure.Functions.Worker.FunctionInputConverterException: Error converting 1 input parameters for Function 'EchoTimeSpanAsync': Cannot convert input parameter 'value' to type 'System.TimeSpan' from type 'System.String'. Error:System.Text.Json.JsonException: Invalid leading zero before '0'. Path: $ | LineNumber: 0 | BytePositionInLine: 1.
[2023-09-25T19:08:33.118Z] ---> System.Text.Json.JsonReaderException: Invalid leading zero before '0'. LineNumber: 0 | BytePositionInLine: 1.
[2023-09-25T19:08:33.119Z] at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
[2023-09-25T19:08:33.120Z] at System.Text.Json.Utf8JsonReader.ConsumeZero(ReadOnlySpan`1& data, Int32& i)
[2023-09-25T19:08:33.121Z] at System.Text.Json.Utf8JsonReader.TryGetNumber(ReadOnlySpan`1 data, Int32& consumed)
[2023-09-25T19:08:33.122Z] at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
[2023-09-25T19:08:33.123Z] at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
[2023-09-25T19:08:33.124Z] at System.Text.Json.Utf8JsonReader.Read()
[2023-09-25T19:08:33.125Z] at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
[2023-09-25T19:08:33.126Z] --- End of inner exception stack trace ---
[2023-09-25T19:08:33.127Z] at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
[2023-09-25T19:08:33.127Z] Executed 'Functions.EchoTimeSpanAsync' (Failed, Id=53fbfc18-c746-4d37-9fe6-723d025830bc, Duration=68ms)
[2023-09-25T19:08:33.128Z] at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
[2023-09-25T19:08:33.130Z] System.Private.CoreLib: Exception while executing function: Functions.EchoTimeSpanAsync. System.Private.CoreLib: Result: Failure
The message makes it sound like the value was serialized as a standard string (E.g. 00:01:00) while the deserializer expects JSON (E.g. "00:01:00").
Additionally, after failing the logs report the function invocation as having succeeded, while the DTFx reports the correct status of "Failed".
I have traced the issue down to how the WebJobs extension decides to serialize data to the worker. In the case of TimeSpan and other types which serialize to a JSON value type (ie: not an object { }), there is this code which this scenario falls into.
The end result is we erroneously unwrap the JSON input and send across as a strong. For TimeSpan we end up stripping the containing quotes from it.
Repro: Sandbox.Functions.Worker.zip
I created a simple orchestration and activity, which I've attached, that passes a
TimeSpan
parameter. The orchestration is able to deserialize the value, but the activity throws an error:The message makes it sound like the value was serialized as a standard string (E.g.
00:01:00
) while the deserializer expects JSON (E.g."00:01:00"
).Additionally, after failing the logs report the function invocation as having succeeded, while the DTFx reports the correct status of
"Failed"
.This same behavior occurs in versions
1.0.0
,1.0.2
, and1.0.3
of the packageMicrosoft.Azure.Functions.Worker.Extensions.DurableTask
.The text was updated successfully, but these errors were encountered: