-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template warnings only consist of invalid '$when' conditions #9074
Comments
@sbaluja - Could you please share more details on how you are calling this function. Please share small piece of code sample and any documentation you are referring to. |
Consider the following Adaptive Card JSON with an invalid property for size (Valid values: "small", "default", "medium", "large", "extraLarge"): {
"type": "AdaptiveCard",
"body": [{
"type": "TextBlock",
"size": "big",
"weight": "bolder",
"text": "Sample Title"
},
{
"type": "ColumnSet",
"columns": [{
"type": "Column",
"items": [{
"type": "Image",
"style": "Person",
"url": "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
"size": "Small"
}],
"width": "auto"
},
{
"type": "Column",
"items": [{
"type": "TextBlock",
"weight": "Bolder",
"text": "Matt Hidinger",
"wrap": true
},
{
"type": "TextBlock",
"spacing": "None",
"text": "Created {{DATE(2017-02-14T06:08:39Z,SHORT)}}",
"isSubtle": true,
"wrap": true
}
],
"width": "stretch"
}
]
},
{
"type": "TextBlock",
"text": "Sample Description",
"wrap": true
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5"
} The following code within the C# WPF SDK generates an AdaptiveCardParsedResult object where AdaptiveCardTemplate template = new AdaptiveCardTemplate(cardJson);
var cardJson = template.Expand();
var parsedCard = AdaptiveCard.FromJson(cardJson); The property
However, the Javascript SDK does not behave this way, with the same JSON const template = new Template(payloadJSON);
const payload = template.expand({}); The function I've looked through the source code for when the /**
* Getter method for the array of warning strings
* @returns An array storing any warnings that occurred while expanding the template
*/
public getLastTemplateExpansionWarnings(): string[] {
return this.templateExpansionWarnings;
} |
Problem
The behavior of the Template.getLastTemplateExpansionWarnings() function differs from other SDKs, such as the .NET WPF SDK. Currently, the list of warnings returned contains only warnings related to $when conditions, with no other types of warnings being included.
Upon reviewing the source code, it appears that the templateExpansionWarnings array is only populated for invalid $when conditions. However, the description for this array states that it "stores any warnings that occurred while expanding the template," which does not align with the current implementation.
Expected behavior
To resolve this, either the list of warnings should be expanded to include other types of warnings, or the behavior should be documented to clarify that only $when conditions are currently reported. As it stands, the current implementation is misleading.
The text was updated successfully, but these errors were encountered: