I'm using liquid templates in an Azure Standard Logic App. I have a null / empty test at the beginning of the file that is behaving differently (and weirdly) to LiquidJS and online liquid playgrounds that I test.
This is the statement:
{% assign itemExists = content.existing != null and content.existing.UID != null and content.existing.UID != "" -%}
then I use it later to generate some GraphQL:
{% if itemExists -%}
_a0: updateFoo(input: {
UID: "{{ content.existing.UID }}"
{% else -%}
_a0: insertFoo(input: {
{% endif -%}
The problem is that UID is an empty string ""
and yet it's following the first if
path, thereby producing the output:
_a0: updateFoo(input: {
UID: ""
I've verified that the UID is an empty string in the logic app run history.
I wrote a quick Jasmine test using exactly the same liquid file, and the same inputs from the logic app, using LiquidJS, and it works fine.
Is this a bug in DotLiquid used in logic apps? If so, how can I get around it?
Update 1:
It only shows when you assign the test to a variable, and then try and use that variable in an if
test. This:
{% assign test = "asdf" -%}
{% assign isNullOrWhitespace = test == null or test == empty %}
isNullOrWhitespace is: {{ isNullOrWhitespace }}
Produces isNullOrWhitespace is: asdf
instead of the expected isNullOrWhitespace is: false
Update 2:
Bug report here: https://github.com/dotliquid/dotliquid/issues/537
Yes, in Liquid if its even "" a empty string it doesnt consider as null it will consider as not null.
You can use something like below example:
If its not empty:
Output:
If its empty:
Output:
For understanding you can execute code here
Edit: