(Postgres) Node with empty output destroys item thread: Multiple matching items for expression [item 0]

Describe the problem/error/question

When using a postgres node to search if a certain record is in there, and it not having output, I can not refer back to items earlier in the workflow.
We are using postgres to keep track of records in our flow which we already processed, and to make sure this works properly we need to search if it’s already present. If it’s not present then we still want to continue with the flow, but this doesn’t work anymore since there is no item (only an empty output).

I would be expecting 3 empty outputs, which still refer to the items from earlier in the flow. However I only get 1 empty output and all threads are gone.


How do I make sure that this scenario would work? Why is the empty output not generated 3 times on the 3 items and hold the thread?

What is the error message?

Multiple matching items for expression [item 0]

An expression here won’t work because it uses .item and n8n can’t figure out the matching item. (There are multiple possible matches)

Please share your workflow

Share the output returned by the last node

{
  "errorMessage": "Multiple matching items for expression [item 0]",
  "errorDetails": {},
  "n8nDetails": {
    "nodeName": "Edit Fields",
    "nodeType": "n8n-nodes-base.set",
    "nodeVersion": 3.4,
    "itemIndex": 0,
    "parameter": "assignments",
    "time": "04/11/2024, 21:21:08",
    "n8nVersion": "1.61.0 (Self Hosted)",
    "binaryDataMode": "default",
    "stackTrace": [
      "NodeOperationError: Invalid expression",
      "    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Set/v2/manual.mode.js:197:15)",
      "    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Set/v2/SetV2.node.js:303:57)",
      "    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:722:42)",
      "    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:711:66",
      "    at processTicksAndRejections (node:internal/process/task_queues:95:5)",
      "    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1141:20"
    ]
  }
}
instance information

Debug info

core

  • n8nVersion: 1.61.0
  • platform: docker (self-hosted)
  • nodeJsVersion: 20.17.0
  • database: sqlite
  • executionMode: regular
  • concurrency: -1
  • license: community
  • consumerId: unknown

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: memory

pruning

  • enabled: true
  • maxAge: 336 hours
  • maxCount: 10000 executions

Generated at: 2024-11-04T20:29:35.122Z

Thanks a lot!

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Its already there Mr.Automated message

@jan Is this intended? Seems like a bug with the thread

hello @drivn

try this option

by default, n8n will batch all items in a single query

@barn4k It still only outputs 1 item, even though 3 items are input.
Also is the referencing of items earlier in the thread still not working.


I do see however that when there is an “error” (like trying to select from the wrong database) it outputs 3 items weirdly.

This “always output data” just does it once (if lets say all 3 items are not found) which is something I did not expect.

Hm… can’t reproduce it

Everything is ok even if the node won’t find a matching row in the table

But anyway if the postgres node doesn’t find anything for the input item, the output will contain less items, so the matching item style won’t work after that node. You can use a Merge node to connect the postgres and Filter nodes. E.g.

then you can use the {{ $json.field }} or {{ $('Merge').item.json.field }} syntax starting from the Merge node