microsoft / botframework-components

The repository for components built by Microsoft for the Azure Bot Framework.
https://aka.ms/botdocs
MIT License
113 stars 82 forks source link

AdaptiveCards data property does not handle null values properly #1343

Closed davhdavh closed 2 years ago

davhdavh commented 2 years ago

Describe the bug

image if dialog.config.Site is null, the renderer behaves as if the given object has no .Site at all and just outputs "${$root.Site}".

Also, This defeats the purpose of coalesce function which REQUIRES the value to be null (to use 2nd arg), not just an empty string.

Version

1.3

To Reproduce

  1. set a property in an object to null, e.g. dialog.Site = null
  2. use object in data, i.e. =dialog 3a. use ${$root.Site} somewhere in adaptive card 3b. use ${coalesce($root.Site, "default")}

Expected behavior

3a. rendered text is "", or "null", or "(null)". NOT "${$root.Site}" 3b. rendered text is "default"

dmvtech commented 2 years ago

Hello @davhdavh

I'm confused on what $root is. Is that supposed to be a value in the template? i.e. are you using Adaptive Card templating? If so, that is currently not supported. Please see here for more information: https://github.com/microsoft/botframework-sdk/issues/6477

If root is an object or property in memory scope, you must use the full 'path' to that using a supported memory scope. You cannot use your own memory scope. For example if root.Site is supposed to be the same as dialog.config.Site, then you must use $dialog.config.Site.

More info on memory scopes: https://docs.microsoft.com/en-us/composer/concept-memory?tabs=v2x#properties-and-memory-scopes

If I misunderstood the situation/scenario; please let me know and give more information that will help me understand. Thank you.

Conversation flow and memory in Bot Framework Composer
Properties and memory scopes track your bot's active state, such as conversational flows and collect information during conversations.
dmvtech commented 2 years ago

Closing due to lack of response.