Gotchas
The mistakes that most often break expressions in Sommatic AI workflows — object literals, fields that start and end with an expression, text conversion, wrapped code results, renamed nodes, literal braces — and how to avoid each one.
Each item below has caused real failures. Read them before you debug an expression that “should work”.
Object literals need parentheses
Inside the braces, { … } is read as a block of code, not as an object.
| Write | Not |
|---|---|
{{ ({ id: $json.id }) }} | {{ { id: $json.id } }} |
A field that starts and ends with an expression
A value such as {{ $json.first }}.{{ $json.last }} starts with {{ and ends with }}, so it is read as one single
expression and fails. Write one expression that builds the text:
{{ $json.first + '.' + $json.last }}Text before the first expression or after the last one (Name: {{ $json.first }} {{ $json.last }}) avoids the
problem too.
Mixed fields turn everything into text
As soon as a field has text around an expression, the result is a string:
- Numbers and booleans become
"42"and"true". When the node expects a number or a boolean, use a pure field. - Objects and lists are inserted as JSON.
undefinedandnullare inserted as the wordsundefinedandnull. Use$ifEmpty(value, '')or?? ''.- A bare
$nowis inserted as a quoted JSON string. Format it:$now.toISO()or$now.toFormat('yyyy-LL-dd').
The result of a code node is wrapped
code.js and code.python return { result, logs }. The next node reads $json.result.total, not $json.total.
From further down: $('Compute totals').item.json.result.total.
flow.if and flow.switch pass the input through
flow.if and flow.switch only choose a port: the node after them
receives the same input they received. If flow.if itself fails, it leaves through error without data, so nodes on
that branch should read what they need with $('…').
Conditions with and without braces
In flow.if, expr must produce a boolean:
- With braces, it is JavaScript:
{{ $json.age >= 18 }}. Return a real comparison, not a value that is only truthy. - Without braces, it is JSONata, evaluated against the input: write
age >= 18. The JSONata text$json.age >= 18is always false.
In data.transform, braces must return an object
data.transform takes JSONata. If you write a pure JavaScript expression instead, make it return an object or a list,
which becomes the node output: {{ ({ total: _.sumBy($json.items, 'qty') }) }}.
Renaming a node breaks its readers
$('Node label') finds the node by its label. After a rename, update every expression that uses the old label. Two
nodes with the same label are ambiguous: keep labels unique.
A node that did not run reads as empty
$('X').item returns { json: {} } for a node that has not run in this execution, so reading a field gives
undefined. Use $('X').isExecuted when the branch is optional. Empty values may also arrive as {} instead of
null: test them with $ifEmpty or $isEmpty.
There is no escape for double braces
Every {{ in a node field starts an expression, including fields that hold code. When you need literal double
braces in a text, produce them with an expression:
Template marker: {{ '{' + '{' }}name{{ '}' + '}' }}In code.js and code.python, avoid writing two opening braces together, including Python f-string escapes; see
code nodes.
Quotes inside JSON
When a workflow is stored as JSON (exported, or kept in Git), double quotes inside an expression must be escaped as
\". Prefer single quotes in expressions: {{ $json.status === 'active' }}.
The execution field is not $execution
Many nodes have a configuration field called execution with retry and timeout settings. It has nothing to do with the
$execution variable, which holds the ids of the run.
One item per node
$input.all() and $('X').all() return one item. To process a list item by item, use
flow.split and flow.join, or work on the whole list with
map, filter or lodash.
Dates use the server’s time zone
$now and $today are in the server’s zone. Call setZone('America/Bogota') (or your zone) before formatting or
comparing calendar days.
$uuid changes on every read
{{ $uuid }} gives a new value each time. Generate the id once in a node and read it from there.