Repository navigation
Error in Sending Adaptive Card with People Picker to Message #1476
Description
Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.
Version
What package version of the SDK are you using.
4.14.2
Describe the bug
Give a clear and concise description of what the bug is.
When sending message using adaptive card that contains a People Picker with dataset, Activity can't be serialized (FlatterningSerializer throws error):
Caused by: java.lang.ClassCastException: class com.fasterxml.jackson.databind.node.ArrayNode cannot be cast to class com.fasterxml.jackson.databind.node.ObjectNode (com.fasterxml.jackson.databind.node.ArrayNode and com.fasterxml.jackson.databind.node.ObjectNode are in unnamed module of loader 'app')
at com.microsoft.bot.restclient.serializer.FlatteningSerializer.serialize(FlatteningSerializer.java:187) ~[bot-connector-4.14.2.jar:4.14.2]
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480) ~[jackson-databind-2.13.3.jar:2.13.3]
... 27 common frames omitted
To Reproduce
Steps to reproduce the behavior:
1 Prepare an adaptive card containing People Picker:
{
"type": "Input.ChoiceSet",
"choices": [],
"choices.data": {
"type": "Data.Query",
"dataset": "graph.microsoft.com/users?scope=currentContext"
},
"isMultiSelect": true,
"placeholder": "Choose at least one person for this feedback",
"label": "Request to",
"style": "filtered",
"id": "userId"
},- Send card as message
- See error in log
Expected behavior
Give a clear and concise description of what you expected to happen.
Expect adaptive card to be sent to chat
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
The same adaptive card works for Task Module.
The problem is in FlatterningSerializer, where it tries to flat "choices.data", how ever, this can't be done, for the expected flatterned data is:
choices: {
data: {..}
}but there's already a choices: [] existing. These two can't match.
Activity
tdurnford commentedon Jun 29, 2022
John Day (@johnmiroki) What channel are you using?
johnmiroki commentedon Jun 30, 2022
TJ Durnford (@tdurnford) Teams channel is used.
ram-xv commentedon Jun 30, 2022
Thanks, John Day (@johnmiroki), I'm investigating this.
ram-xv commentedon Jul 7, 2022
Hi John Day (@johnmiroki),
Thanks for raising this issue, I was able to repro.
Looks like when sending People Picker in Adaptive Cards, the following error message is thrown:
Error source code:
/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/FlatteningSerializer.java
johnmiroki commentedon Jul 7, 2022
@ramfattah Thank you for the confirmation! May I ask what's the next action from Microsoft?
ram-xv commentedon Jul 18, 2022
Thank you John Day (@johnmiroki), we are working on this fix for the next patch release.
ram-xv commentedon Jul 21, 2022
Attached is a sample repro zip project. Combined sample 07.using-adaptive-cards & 46.teams-auth.
Call stack to FlatterningSerializer:
johnmiroki commentedon Jul 21, 2022
@ramfattah Thanks a lot!
tracyboehrer commentedon Jul 21, 2022
John Day (@johnmiroki) This is next on my list. Ram and I will resolve it and include in the next patch release for Java. I don't have a solid ETA on that release, but it's sooner rather than later.
johnmiroki commentedon Jul 23, 2022
tracyboehrer (@tracyboehrer) good to hear. Thank you very much!
johnmiroki commentedon Nov 5, 2022
tracyboehrer (@tracyboehrer) Hi Tracy, any ETA regarding this fix? Much appreciated!
tracyboehrer commentedon Nov 7, 2022
The root of the problem is the 'choices.data' property. It would appear this is a flattened JSON property. I do believe that this should be an object under the 'choices' array. It's a tricky issue and it will take me more research to understand this JSON notation. What the existing FlatteningSerialzier is doing just doesn't handle it correctly.
In other words, I think a mitigating step is to change the JSON.
johnmiroki commentedon Jan 13, 2023
tracyboehrer (@tracyboehrer) agreed. It's rare to use a property as an object and an array at the same time. But the change should be from MS side. We as third party developers can't do much about it.