Skip to content

If statement not working #22779

@HenBOMB

Description

@HenBOMB

Bug Description

Image

How do I explain this?
The if statement is returning "true" as shown but during execution / runtime its failing as if it were false?

To Reproduce

  1. Add chat trigger and create an agent node and check intermediate steps.
  2. Connect an if statement to the output and paste expression: {{ JSON.parse($('Your Agent').first().json.intermediateSteps[0].observation).some(x => JSON.parse(x.response?.[0]?.text)?.[0].results != null) && !$('Your Agent').first().json.intermediateSteps.some(x => x.action.messageLog[0].kwargs.tool_calls[0].args.tool === 'SomeTool')}}
    (annoying to parse so many times but ok)
  3. Implement "SomeTool" that outputs { results: [] } and connect it to the agent.

Expected behavior

The if statement should fail as shown in the screenshot.
Even if it shows true its truly not because its failing.

Debug Info

Debug info

core

  • n8nVersion: 1.121.2
  • platform: docker (cloud)
  • nodeJsVersion: 22.21.0
  • nodeEnv: production
  • database: sqlite
  • executionMode: regular
  • concurrency: 20
  • license: community
  • consumerId: 00000000-0000-0000-0000-000000000000

storage

  • success: all
  • error: all
  • progress: false
  • manual: false
  • binaryMode: filesystem

pruning

  • enabled: true
  • maxAge: 720 hours
  • maxCount: 25000 executions

client

  • userAgent: mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, like gecko) chrome/140.0.0.0 safari/537.36
  • isTouchDevice: false

Generated at: 2025-12-04T22:08:37.774Z

Operating System

ex. Ubuntu Linux 22.04

n8n Version

1.121.2

Node.js Version

ex. 22.16.0

Database

SQLite (default)

Execution mode

main (default)

Hosting

n8n cloud

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions