question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Error when deserializing sessionId in JSON

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wonnercommented, Aug 7, 2023

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

1reaction
github-actions[bot]commented, Aug 7, 2023

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using HTTP or REST API as source in Copy Activity
My REST API call requires I pass a sessionId in the header. ... Error occurred when deserializing source JSON file '../applications'.
Read more >
Net Core 3.0 TimeSpan deserialization error - Fixed in . ...
To fix this error either change the JSON to a JSON primitive value (e.g. string, number, boolean, null) or change the deserialized type...
Read more >
webservices - Getting error while deserialize
A common cause is that the server is responding with a HTML page that contains error information rather than the JSON.
Read more >
Solved: Cannot deserialize the current JSON array
Cannot deserialize the current JSON array. I'm getting an error when I try to convert csv to json. I've tried many different ways....
Read more >
How to use sessions
By default, Django serializes session data using JSON. You can use the SESSION_SERIALIZER setting to customize the session serialization format.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found