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.

[Rendering] Discrepancy (in js and C# libraries) while rendering an AC template containing an invalid "$when" condition

See original GitHub issue

Target Platforms

NodeJS

SDK Version

latest

Application Name

Microsoft Search

Problem Description

We observe that, when the Adaptive card contains an invalid $when condition (an example of which is given below)

Example: “$when”: “https://searchuxcdn.azureedge.net/designerapp/images/servicenow-icon.png!=\“\”

The C# Templating library throws an exception, when we try to bind the template with data -> adaptiveTemplate.Expand(source), with the following exception message: “String was not recognized as a valid Boolean.”

However, the JS library treats it as a valid string and displays the result evaluating the condition to true. Can this discrepancy be fixed ?

Screenshots

No response

Card JSON

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "TextBlock",
            "size": "Medium",
            "weight": "Bolder",
            "text": "${title}",
            "$when": "https://searchuxcdn.azureedge.net/designerapp/images/servicenow-icon.png!=\"\""
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.5"
}

Sample Code Language

C#

Sample Code

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
jwoo-msftcommented, Apr 28, 2022

@anna-dingler

Can you elaborate on what constitutes invalid? for example, does invalid include syntax error in template language and run time error at AEL?

When you say returning false, do you implying dropping adaptive element that has when?

0reactions
dclauxcommented, May 2, 2022

I agree with the proposed resolution: if $when is specified, it cannot be ignored (as opposed to what JS currently does). If it’s not an expression, if it’s an expression that doesn’t return a Boolean, or if it’s an invalid expression, it should always return false. Throwing (as .NET currently does in one case) isn’t desirable IMO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue template or render function not defined yet I am using ...
In my case, I was getting the error because I upgraded from Laravel Mix Version 2 to 5. In Laravel Mix Version 2,...
Read more >
Conditional Rendering | Vue.js
The directive v-if is used to conditionally render a block. The block will only be rendered if the directive's expression returns a truthy...
Read more >
Render Functions & JSX
Declaring Render Functions ​. When using templates with Composition API, the return value of the setup() hook is used to expose data to...
Read more >
v-if vs. v-show - Vue Conditional Rendering
Conditional rendering is the ability to control whether or not template code is rendered. We can do this using the current state of...
Read more >
A list of open source C++ libraries
The objective of this page is to build a comprehensive list of open source C++ libraries, so that when one needs an implementation...
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