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

Incorrect serialization of activity parameters in version 1.1.0 #245

Closed
recumbented opened this issue Nov 15, 2023 · 6 comments
Closed

Incorrect serialization of activity parameters in version 1.1.0 #245

recumbented opened this issue Nov 15, 2023 · 6 comments
Labels
bug Something isn't working needs: investigation P1

Comments

@recumbented
Copy link

recumbented commented Nov 15, 2023

In version 1.1.0, Activity input serialization may be incorrect.
String type input is enclosed in double-quoted.

Environment

  • Windows 11 22H2 x64
  • .NET 8.0.0
  • Microsoft.Azure.Functions.Worker 1.19.0
  • Microsoft.Azure.Functions.Worker.Sdk 1.16.2
  • Microsoft.Azure.Functions.Worker.Extensions.Http 3.1.0
  • Microsoft.Azure.Functions.Worker.Extensions.DurableTask 1.1.0

Code for repro

public static class Trigger
{
    [Function("Trigger")]
    public static async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequestData req, FunctionContext executionContext, [DurableClient] DurableTaskClient durableTaskClient)
    {
        var response = req.CreateResponse(HttpStatusCode.OK);

        await durableTaskClient.ScheduleNewOrchestrationInstanceAsync("Orchestration");
        return response;
    }

    [Function("Orchestration")]
    public static async Task RunOrchestration([OrchestrationTrigger] TaskOrchestrationContext context)
    {
        var logger = context.CreateReplaySafeLogger(nameof(RunOrchestration));
        var input = context.GetType().Assembly.GetName().Version;
        var output = await context.CallActivityAsync<String>("Echo", input);
        logger.LogInformation(output);
    }

    [Function("Echo")]
    public static String Echo([ActivityTrigger] String parameter, FunctionContext context)
    {
        var logger = context.GetLogger(nameof(Echo));
        logger.LogInformation(parameter);
        return parameter;
    }
}

Output in 1.0.4:

[2023-11-15T07:42:18.283Z] Executing 'Functions.Trigger' (Reason='This function was programmatically called via the host APIs.', Id=84299be6-145a-47c9-90bc-1a3c47d1d59a)
[2023-11-15T07:42:18.435Z] Scheduling new Orchestration orchestration with instance ID '54c04d4fa43542c4862ff1190f5bcd0b' and 0 bytes of input data.
[2023-11-15T07:42:18.672Z] Executed 'Functions.Trigger' (Succeeded, Id=84299be6-145a-47c9-90bc-1a3c47d1d59a, Duration=416ms)
[2023-11-15T07:42:21.660Z] Host lock lease acquired by instance ID '0000000000000000000000005732CFD6'.
[2023-11-15T07:42:22.323Z] Executing 'Functions.Orchestration' (Reason='(null)', Id=b3ecf065-7887-4bb5-96d5-0e8673a0ed3c)
[2023-11-15T07:42:22.403Z] Executed 'Functions.Orchestration' (Succeeded, Id=b3ecf065-7887-4bb5-96d5-0e8673a0ed3c, Duration=98ms)
[2023-11-15T07:42:22.454Z] Executing 'Functions.Echo' (Reason='(null)', Id=aeea6084-4c3f-456c-b477-943ec0819732)
[2023-11-15T07:42:22.459Z] 1.0.4.0
[2023-11-15T07:42:22.460Z] Executed 'Functions.Echo' (Succeeded, Id=aeea6084-4c3f-456c-b477-943ec0819732, Duration=10ms)
[2023-11-15T07:42:22.506Z] Executing 'Functions.Orchestration' (Reason='(null)', Id=4e91a770-174c-41d4-9acb-6ad24060e1e6)
[2023-11-15T07:42:22.516Z] 1.0.4.0
[2023-11-15T07:42:22.523Z] Executed 'Functions.Orchestration' (Succeeded, Id=4e91a770-174c-41d4-9acb-6ad24060e1e6, Duration=19ms)

Version number 1.0.4.0 is not quoted.

Output in 1.1.0:

For detailed output, run func with --verbose flag.
[2023-11-15T07:42:55.271Z] Executing 'Functions.Trigger' (Reason='This function was programmatically called via the host APIs.', Id=0be87bf7-df93-47ac-8cde-2d6c2c026b01)
[2023-11-15T07:42:55.417Z] Scheduling new Orchestration orchestration with instance ID '0843e4a20a264ef0878656fbb538b8d3' and 0 bytes of input data.
[2023-11-15T07:42:55.649Z] Executed 'Functions.Trigger' (Succeeded, Id=0be87bf7-df93-47ac-8cde-2d6c2c026b01, Duration=404ms)
[2023-11-15T07:42:56.683Z] Host lock lease acquired by instance ID '0000000000000000000000005732CFD6'.
[2023-11-15T07:42:57.326Z] Executing 'Functions.Orchestration' (Reason='(null)', Id=5e6b5b18-2b58-47c1-bd36-1c04fd3d808b)
[2023-11-15T07:42:57.408Z] Executed 'Functions.Orchestration' (Succeeded, Id=5e6b5b18-2b58-47c1-bd36-1c04fd3d808b, Duration=100ms)
[2023-11-15T07:42:57.459Z] Executing 'Functions.Echo' (Reason='(null)', Id=9ee09cfa-ffa4-4641-b428-db3d1ae0554d)
[2023-11-15T07:42:57.464Z] "1.1.0.0"
[2023-11-15T07:42:57.465Z] Executed 'Functions.Echo' (Succeeded, Id=9ee09cfa-ffa4-4641-b428-db3d1ae0554d, Duration=9ms)
[2023-11-15T07:42:57.511Z] Executing 'Functions.Orchestration' (Reason='(null)', Id=4e735bd5-4f44-4579-b6db-7a6254a6820b)
[2023-11-15T07:42:57.520Z] "1.1.0.0"
[2023-11-15T07:42:57.526Z] Executed 'Functions.Orchestration' (Succeeded, Id=4e735bd5-4f44-4579-b6db-7a6254a6820b, Duration=18ms)

Version number 1.1.0.0 is double-quoted.

@horatiu-stoianovici
Copy link

horatiu-stoianovici commented Nov 16, 2023

I am facing the same issue with 1.1.0, passing in a string as input to my activity results in extra quotes being added.
e.g. if I am passing in the value hello world, debugging the activity class shows that the value received by the activity is "hello world".
It looks to me like an extra JSON serialization is happening on the string input where there is no deserialization happening afterwards

The only things different for my environment are:

  • using .NET 6.0 (vs .NET 8.0 from original issue)
  • Microsoft.Azure.Functions.Worker 1.20.0 (vs 1.19.0)

@jviau jviau added the bug Something isn't working label Dec 4, 2023
@jviau
Copy link
Member

jviau commented Dec 4, 2023

This is a regression from a different fix for types that serialized to/from a simple string. Will need to investigate why it is not unwrapping the quotes from the JSON payload.

@kweebtronic
Copy link

glad I found this issue, facing the same problem

  • Microsoft.Azure.Functions.Worker.Extensions.DurableTask Version="1.1.0"
  • Microsoft.Azure.Functions.Worker Version="1.20.0"
  • NET 8.0

@lilyjma lilyjma added the P1 label Jan 4, 2024
@jviau
Copy link
Member

jviau commented Jan 9, 2024

@jviau jviau closed this as completed Jan 9, 2024
@prashantagrawalcrowe
Copy link

Resolved by Azure/azure-functions-durable-extension#2708

Currently, I am using Microsoft.Azure.Functions.Worker.Extensions.DurableTask 1.1.0, so I wanted to ask in which version this issue would be resolved?

@jviau
Copy link
Member

jviau commented Jan 13, 2024

It will be resolved in the next release - 1.1.1. Which we should be out in the next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs: investigation P1
Projects
None yet
Development

No branches or pull requests

6 participants