Issues with MongoDB find and update node

Problem:

I’m updating Documents in MongoDB using find and update node. I’ve _id of document which is created earlier. When I try to set it to “_id” variable in set node, its adding two double quotes. Mongodb node is returning “input must be a 24 character hex string, 12 byte Uint8Array, or an integer” ERROR.


When I add …replace(/^“|”$/g, ‘’) method to string to avoid 2 quotes it’s converting _id value to null, so its not working either.

As per some other posts here in forum, this issue exists for months, yet no solution. Mapping {{ $json._id }} wont work as its not a key.
(MongoDB node "Find and Update" error)

Can someone please solve it asap? I am debugging it for hours.

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Information on your n8n setup

Debug info

core

  • n8nVersion: 1.63.4
  • platform: npm
  • nodeJsVersion: 20.18.0
  • database: sqlite
  • executionMode: regular
  • concurrency: 20
  • license: community
  • consumerId: 00000000-0000-0000-0000-000000000000

storage

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

pruning

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

Generated at: 2024-12-17T09:14:04.969Z

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:

i just had this problem a few hours ago and my working workaround is to use two set nodes after each other, one which just sets_id without modifying and the second one which replaces the double quotes. I’ll update my comment tomorrow with an example.

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