n8n - 💡(How to fix) Fix Nested object is unexpectedly mutated across sibling branches during execution [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
n8n-io/n8n#29127Fetched 2026-04-25 06:21:39
View on GitHub
Comments
2
Participants
3
Timeline
5
Reactions
0
Timeline (top)
commented ×2labeled ×1mentioned ×1subscribed ×1

Error Message

Error.json

  • error: all

Root Cause

This report is not about Set/Edit Fields specifically. I am using Edit Fields nodes only as a minimal reproducible example because they make the issue easier to demonstrate.

RAW_BUFFERClick to expand / collapse

Bug Description

A nested object appears to be shared by reference across sibling branches during workflow execution.

This report is not about Set/Edit Fields specifically. I am using Edit Fields nodes only as a minimal reproducible example because they make the issue easier to demonstrate.

When the same nested object is passed into two sibling branches, changing a nested property in one branch also changes the object seen by the other branch, even when the other branch only copies the original object and does not modify it.

As a result, outputs that should still contain the original value end up showing the mutated value from a sibling branch.

This is unexpected because branch-local changes should not mutate data used by another sibling branch, and previously produced outputs should remain stable for that execution.

To Reproduce

  1. Create a workflow with a Manual Trigger.

  2. Add a node that creates this object: { "object": { "string_one": "value_1", "string_two": "value_2" } }

  3. Connect that node to two sibling branches.

  4. In the first sibling branch:

    • copy the nested object with: object = {{$json.object}}
    • then change: object.string_one = "new_value"
  5. In the second sibling branch:

    • only copy the nested object with: object = {{$json.object}}
    • do not change any nested property
  6. Execute the workflow.

  7. Observe that the second sibling branch may also show: { "object": { "string_one": "new_value", "string_two": "value_2" } } instead of keeping the original value_1.

I attached a minimal workflow JSON that reproduces this more clearly.

Error.json

Expected behavior

Each sibling branch should work with an independent value for the nested object.

If one branch changes a nested property, that change should stay only in that branch.

The other sibling branch, which only copies the object and does not modify it, should still keep: { "object": { "string_one": "value_1", "string_two": "value_2" } }

More generally, data used by one sibling branch should not be mutated by another sibling branch during the same execution.

Debug Info

Debug info

core

  • n8nVersion: 2.17.7
  • platform: docker (self-hosted)
  • nodeJsVersion: 24.14.1
  • nodeEnv: production
  • database: sqlite
  • executionMode: regular
  • concurrency: -1
  • license: enterprise (production)
  • consumerId: 7874036b-51f7-4432-965f-34f0e25ad1f9

storage

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

pruning

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

client

  • userAgent: mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/147.0.0.0 safari/537.36 edg/147.0.0.0
  • isTouchDevice: false

Generated at: 2026-04-25T00:36:16.307Z

Operating System

easypanel

n8n Version

2.17.7

Node.js Version

24.14.1

Database

SQLite (default)

Execution mode

main (default)

Hosting

self hosted

extent analysis

TL;DR

The issue can be resolved by ensuring that each sibling branch works with a deep copy of the nested object instead of a shared reference.

Guidance

  • The problem arises because the nested object is shared by reference across sibling branches, causing changes in one branch to affect the other.
  • To verify this, check the workflow execution and observe how changes in one branch impact the output of the other branch.
  • To mitigate this, use a deep copy function to create an independent copy of the nested object for each branch, ensuring that changes in one branch do not affect the other.
  • Consider using a library like Lodash to create a deep copy of the object, or use the JSON.parse(JSON.stringify(obj)) method as a simple alternative.

Example

const _ = require('lodash');

// Create a deep copy of the nested object
const objectCopy = _.cloneDeep($json.object);

Notes

This solution assumes that the issue is caused by the shared reference to the nested object. If the problem persists after implementing the deep copy solution, further investigation into the workflow and node configurations may be necessary.

Recommendation

Apply a workaround by using a deep copy function to create an independent copy of the nested object for each branch, as this will prevent changes in one branch from affecting the other.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Each sibling branch should work with an independent value for the nested object.

If one branch changes a nested property, that change should stay only in that branch.

The other sibling branch, which only copies the object and does not modify it, should still keep: { "object": { "string_one": "value_1", "string_two": "value_2" } }

More generally, data used by one sibling branch should not be mutated by another sibling branch during the same execution.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING