Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.26k stars 4.61k forks source link

[BUG] Error when deserializing sessionId in JSON #38040

Open paulohumberto42 opened 1 year ago

paulohumberto42 commented 1 year ago

Library name and version

Azure.Analytics.Synapse.Artifacts 1.0.0-preview.18

Describe the bug

The SessionId property is mapped as int64 but the API is returning it as string. image image

Expected behavior

The property type matches the API response, and the deserialization works.

Actual behavior

An exception is raised. System.InvalidOperationException: 'The requested operation requires an element of type 'Number', but the target element has type 'String'.'

Reproduction Steps

var r = await notebookRunClient.GetSnapshotAsync("7942e5c5-e9f1-42b6-88cd-c59a6afa2f4a");
var r2 = await notebookRunClient.GetStatusAsync("7942e5c5-e9f1-42b6-88cd-c59a6afa2f4a");

I created a custom HttpPipelinePolicy to workaround the problem:

    public override async ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline)
    {
        await ProcessNextAsync(message, pipeline);

        var json = await JsonSerializer.DeserializeAsync<JsonObject>(using message.Response.ContentStream);
        json["result"]["sessionId"] = long.Parse(json["result"]["sessionId"].GetValue<string>());

        var memoryStream = new MemoryStream();

        await JsonSerializer.SerializeAsync(memoryStream, json);
        memoryStream.Position = 0;
        message.Response.ContentStream = memoryStream;
    }

Environment

No response

github-actions[bot] commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

navba-MSFT commented 1 year ago

Adding service team to look into this

github-actions[bot] commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @wonner @yanjungao718 @annelo-msft.

wonner commented 1 year ago

Thanks for the report, @kevinzz6 will help fix, thanks.

kevinzz6 commented 1 year ago

@paulohumberto42 fix PR was merged, please check it on next release.

paulohumberto42 commented 1 year ago

Thanks for solving this! Do you know when the next version will be release? This issue is realing impacting our product :(

Petermarcu commented 1 year ago

@kevinzz6 can you share anything on release timeline?

wonner commented 1 year ago

Next release will in Oct. Thanks.