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.

Deserializing a card twice in .NET fails with ID collision errors

See original GitHub issue

Platform

What platform is your issue or question related to? (Delete other platforms).

  • .NET object model

Author or host

Someone deserializing cards (issue was reported by internal MS customer)

Version of SDK

NuGet 1.2.0

Issue

If you use JSON.NET to deserialize a card that’s within another object and then immediately deserialize the same card again, a collision ID occurs… even though it’s deserializing two separate instances.

It seems like the collision ID logic is using a shared static or something when the AdaptiveCard isn’t the top-level thing being deserialized.

Repro code (install latest .NET 1.2.0 from NuGet)

public class cards
{
    public AdaptiveCard Card { get; set; }
}

private void Test()
{
    string cardsJson = @"{ ""card"": {
""type"": ""AdaptiveCard"",
""version"": ""1.0"",
""body"": [
{
    ""type"": ""Input.Text"",
    ""id"": ""myTextInput""
}
]
} }";

    cards fullcardresponse = JsonConvert.DeserializeObject<cards>(cardsJson);

    // Deserialize again, exception gets thrown here
    fullcardresponse = JsonConvert.DeserializeObject<cards>(cardsJson);
}
AdaptiveCards.AdaptiveSerializationException: 'Collision detected for id 'myTextInput''

Workaround

If you use the official AdaptiveCard.FromJson method, it works fine. This problem is limited to deserializing a JSON object that inside it contains an Adaptive Card. So workaround is that you could parse the initial object and then grab the card as a JObject and then parse that using the official parsing method

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
nadoylemsftcommented, Sep 16, 2021

I was able to stop this from occurring by setting the Attachment Content as card.ToJson() instead of straight to card

//Added .ToJson() 
prompt.Attachments.Add(new Attachment { ContentType = AdaptiveCard.ContentType, Content = card.ToJson() });
2reactions
shalinijoshi19commented, Aug 7, 2019

@paulcam206 mind taking a stab at this since you are the id collision guru 😃 thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

the json property name for collides with another property
NET Core - The JSON property name for collides with another property, Flake it till you make it: how to detect and deal...
Read more >
An Exploration of JSON Interoperability Vulnerabilities
Key Collision: Character truncation and Comments; JSON Serialization Quirks; Float and Integer Representation; Permissive Parsing and Other Bugs ...
Read more >
Analyzing Disconnects - Photon Fusion
Analyzing Disconnects. When you build an online multiplayer game, you have to be aware that sometimes connections between clients and servers fail.
Read more >
Troubleshooting - Photon Fusion
If Bolt seems to be functioning incorrectly the first steps to try would be to: If you're still having issues then have a...
Read more >
Troubleshooting Ethernet Collisions
Excessive collisions indicate a problem. Common causes are devices connected as full-duplex on a shared Ethernet, broken NICs, or simply too ...
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