Filter expression evals false but still kept

Describe the problem/error/question

I can’t reproduce this reliably, so I can’t provide an example workflow. In my scenario I use the HTML module to extract a <section> of a page with id =“tracker-app”. Then I process that HTML inside that section. But sometimes the section doesn’t exist or doesn’t extract correctly, so I want to filter those out using the Filter module before the rest of the processing logic.

However, even when {{ $json.hasOwnProperty(‘tracker-app’) }} evaluates to false, the item is still kept. My scenario fails with an error whenever the filter doesn’t catch these.

What is the error message (if any)?

In this step, the item is empty and the expression is definitely false, but the item is still “kept”.

I’ve tried this with the IF node too. Same issue. Is there a better way to test whether a key exists?

Information on your n8n setup

  • n8n version: 1.7.1
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker Amazon ECS
  • Operating system: Alpine Linux

Hi @Lee_S! :wave:

Out of curiosity, do you see the same behaviour when checking if the value is empty? :thinking:

Like I said, I’m having a tough time repoducing it. The workflow below appears to behave correctly, so the isEmpty test seems to work in this simple example, but the hasOwnProperty test also works correctly in that it properly evals false.

Facing the same issue:

Test Workflow:


Using a workaround for now:


Information on your n8n setup

  • n8n version: 1.9.3
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Windows

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.