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.

Bot Builder v4 IgnoreEmptyItemsConverter causes an issue when ReadJson

See original GitHub issue

Platform

Bot Builder v4.0 (dotnet core)

Author or host

web api (Bot Framework)

Version of SDK

1.1

Issue

When deserialize the DialogState which contains the AdaptiveCard, it fails with error "Error reading JArray from JsonReader at

var array = JArray.Load(reader);.

Error: Current JsonReader item is not an array: StartObject. Path 'DialogState.DialogStack.$values[0].State.dialogs.DialogStack.$values[0].State.options.Prompt.attachments.$values[0].content.action"

This caused by [JsonConverter(typeof(IgnoreEmptyItemsConverter<AdaptiveAction>))] attribute on AdaptiveCard which will be called while deserialization but it’s not actually an array yet, as $value holds an array not action (nor body)

"actions": {
    "$type": "System.Collections.Generic.List`1[[AdaptiveCards.ActionBase, AdaptiveCards]], System.Private.CoreLib",
    "$values": [
    {
        "$type": "AdaptiveCards.SubmitAction, AdaptiveCards",
        "type": "Action.Submit",
        "data": "Test",
        "title": "Test"
    }
    ]
}

We should try/catch JArray.Load

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dclauxcommented, Feb 13, 2019

Thank you, this helps.

So it looks like the problem is the Adaptive Card object model isn’t fully compatible with NewtonSoft’s JSON serialization/deserialization algorithm when TypeNameHandling.All is used. Namely, an AdaptiveCard object cannot be round-tripped (FromObject then ToObject) in TypeNameHandling.All mode.

I’ll leave it to @khouzam and @paulcam206 from here (maybe they had already understood all this for that matter.)

0reactions
hansmbakkercommented, May 12, 2020

@v-kydela now I see, that works, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ChoiceSetConverter.ReadJson Method
Indicates if existingValue has a value. serializer: Newtonsoft.Json.JsonSerializer. The calling serializer. Returns. ChoiceSet. The interpreted ...
Read more >
Bot Framework v4 SDK Templates for Visual Studio
Microsoft Bot Builder V4 Templates will help you build new conversational AI bots using the Microsoft Bot Framework v4. Templates. There are ...
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