Guides / n8n Core / Data mapping

Fix n8n Item-Linking Errors After a Merge or Code Node

Diagnose broken `.item` expressions in n8n by tracing pairing through Code, Aggregate, and Merge nodes, then choose a safe repair that preserves the intended record.

FlowPatch diagram showing paired item links crossing a Code node and a Merge node in n8n.
“Info for expressions missing from previous node”, “Multiple matching items for expression”, or “<node> is on another branch” when an expression uses `.item`.
Short answer: An n8n `.item` expression needs one unambiguous lineage from the current item back to the referenced node. A Code node that creates outputs without `pairedItem`, a node that combines several inputs into one item, or an Append merge whose branches remain separate can break or make that lineage ambiguous. Trace the item path first. Preserve pairing when transforming rows; use `.first()`, `.last()`, or an explicit index only when that positional choice is actually the business rule.

What `.item` means in an n8n expression

An n8n item is more than a JSON object. As data moves from node to node, n8n also tracks which incoming item produced each outgoing item. That relationship is item linking, often described as a thread through the workflow. When an expression such as `{{ $("Customers").item.json.email }}` runs, n8n follows the current item’s thread backward until it reaches the named node, then reads the corresponding item. This lets a downstream node retrieve a customer field even when several records are being processed at once.

That convenience depends on a relationship n8n can prove. If one incoming row becomes one output row, the relationship is usually straightforward. If a Code node manufactures unrelated rows, an Aggregate node folds many rows into one, or branches are appended without being combined, the expression may have no valid single answer. The error is not necessarily a bad field name or stale execution. It can be a data-lineage problem. Identify the exact node where one-to-one lineage stops before changing expressions throughout the workflow.

Classify the exact error before editing the workflow

A thread map tracing each output item back to its originating input item.
A thread map tracing each output item back to its originating input item.

“Info for expressions missing from previous node” points to a broken thread. A Code node or third-party node returned data without enough pairing information for n8n to connect each result to its source. “Multiple matching items for expression” means the path exists but reaches more than one candidate in the referenced node, commonly after aggregation or a many-to-one operation. “Node is on another branch” means the item currently being evaluated did not come from the referenced node’s branch. Those messages describe different shapes of data, so the repair should follow the message rather than a generic expression rewrite.

Reproduce the issue with one representative execution and inspect the input and output panes at each node around the first transformation. Record the item count before and after that node, and compare a stable business key such as `customerId` or `orderId`. If the failure appears only on certain rows, check branch conditions and whether a merge waits for both inputs. If the expression preview is null but execution continues, do not assume the data was intentionally empty: the “another branch” case can resolve to null in the editor/runtime context. Verify with a test record from each branch.

The wording usually identifies which part of item lineage needs attention.

Message or symptomWhat n8n cannot establishFirst place to inspect
Info missing from previous nodeWhich source item produced this outputCode, custom, or community node immediately upstream
Multiple matching itemsWhich of several source items is the intended oneAggregate, Summarize, Merge, or many-to-one logic
Node is on another branchA source item on a sibling branch for this outputIF/Switch path and Merge mode
Only some rows return nullA source relationship for those specific rowsBranch membership and keys for failing items

Trace item lineage with a small, controlled run

Use a small test input with at least two records whose IDs are visibly different. One row can hide ambiguity: a workflow may appear correct even though an expression is selecting the only available item by accident. Give each row a stable identifier, then inspect the output after each node until the error first appears. A useful diagnostic table has the node name, number of input items, number of output items, and the IDs present in each. The first stage where IDs disappear, duplicate, or combine is usually the stage to investigate.

For a Code node, distinguish between transforming existing items and constructing new output items. If the output is still derived from one input item at a time, keep the original item and modify its JSON where practical. If the code returns newly constructed output items, the current n8n guidance says to include `pairedItem` when there is more than one incoming item and downstream `.item` references need that lineage. A single output created from multiple inputs does not have one correct parent; decide which source field should be carried forward explicitly instead of inventing a pairing.

const output = items.map((item, i) => ({
  json: {
    customerId: item.json.customerId,
    normalizedEmail: String(item.json.email || "").trim().toLowerCase(),
  },
  pairedItem: i,
}));
return output;
This mapping is appropriate only when each output at index `i` was produced from input item `i`. If code filters, reorders, fans out, or combines items, calculate the source index deliberately; do not copy `i` by habit.

Repair a Code node without masking the data relationship

A Code node output with pairedItem pointing to the input item that produced it.
A Code node output with pairedItem pointing to the input item that produced it.

When the Code node returns a new array, add `pairedItem` to each output and point it to the input item that generated that output. For a simple map where output order and count exactly match the input, the index shown in the example is valid. If the code filters the input, preserve the original input index alongside each row so that a remaining output does not accidentally point to the wrong row. If one input fans out into several outputs, each output can point back to that same source index. When a node has multiple inputs, n8n also supports identifying the relevant input; check the node’s actual input structure before setting that field.

Do not “fix” a broken Code node by changing every later expression to `.first()`. That can make a workflow green while assigning one customer’s email to every order. After editing the node, run at least two distinct input rows through it, then add an expression in a later node that reads a different field from the original source. Confirm each output resolves to the matching ID. If output is a rollup of many records, put the needed parent values into the rollup output itself (for example, an array of source IDs) and reference that explicit result; a singular `.item` parent would misrepresent the aggregation.

Choose Merge mode based on whether rows should stay separate

Append emits the items from one input followed by the items from the other input. It does not, by itself, combine fields from corresponding rows. An item emitted from input one still belongs to input one; it cannot automatically look up a field from a sibling branch that produced a different item. This is why a downstream reference to a node on the other branch can show an “another branch” warning or return null for some outputs. Use Append when the intended result is one longer list of independent items.

Combine is the relevant family when fields from multiple inputs should form the same output item. Select the matching behavior deliberately: matching by position is only valid when both inputs have a guaranteed identical order and cardinality; matching by a field requires a stable key present on both sides; all-pairs combination has very different semantics. After a Merge, inspect a sample output to confirm each row contains the intended fields and that duplicated or unmatched keys behave as expected. A Merge configuration should express the relationship in the data, not just silence the editor warning.

Pick the Merge behavior that matches the intended record relationship.

Desired resultSuitable directionGuardrail
One list containing either branch’s independent rowsAppendDo not expect fields from the other branch on every row
A row enriched with matching fields from both inputsCombine by a stable matching fieldCheck duplicate and unmatched keys
Pair rows by known identical sequenceCombine by positionProve both inputs retain equal order and count
Many inputs summarized into one resultAggregate/Summarize and carry required valuesDo not pretend the result has one unique parent

When `.first()`, `.last()`, or an index is actually safe

Append and Combine merge modes compared by which source rows each output retains.
Append and Combine merge modes compared by which source rows each output retains.

n8n documents `.first()`, `.last()`, and `.all()[index]` as alternatives when the workflow author knows which item position is intended. These methods bypass the need to resolve the current item’s lineage. They are appropriate for a true singleton configuration record, a deliberately selected first result after sorting, or a record whose position is part of a documented contract. They are not generic repairs for a broken thread. Sorting, filtering, pagination, and node-version changes can alter positions.

Before choosing a positional accessor, write the rule in plain language: “use the first active configuration row after the Filter node,” for example. Then enforce that rule in the workflow (sort, filter, and limit the data) and handle the empty case. If the rule is “use the customer related to this order,” use item linking or a key-based lookup, not `.first()`. When uncertain, carry a stable key forward and perform an explicit lookup whose zero-match and duplicate-match behavior is visible.

Common traps that make the error disappear but corrupt results

A common trap is referencing the current node’s output by index while assuming that upstream order never changes. Another is using `.first()` after a search node that can return multiple customers, then reusing that value on every item. A third is switching an Append merge to Combine without choosing a match rule, which can create a Cartesian product or pair unrelated rows. These approaches can turn a visible error into silent data corruption, especially when the sample execution contains only one row.

Also check whether a Code node is set to “Run Once for All Items” or “Run Once for Each Item.” Those modes change the shape of `items` and how the code should create output. Do not assume a community node’s output links correctly merely because built-in nodes usually preserve relationships. If the failure begins at a custom/community node, reduce the workflow to a minimal reproduction and inspect its output; if it omits pairing, the node implementation may need an update or correction. Keep credentials and customer payloads out of public issue reports.

Verification checklist

A decision map for choosing item, first, last, or indexed data references.
A decision map for choosing item, first, last, or indexed data references.
  • Run two or more records with distinct stable IDs through the affected path; verify each output still resolves to the matching source record.
  • Confirm the exact `.item` warning is gone and test an item from each IF/Switch branch, including a no-match branch.
  • After a Merge, inspect actual output JSON and verify cardinality, keys, and unmatched-row behavior—not only the green node status.
  • For a Code node returning new items, set `pairedItem` to the true source index when the output has one source; document any intentional positional accessor.
  • Rerun a production-like test and check downstream writes for duplicate or cross-linked records before enabling the workflow.

Documentation and community threads cited

The diagnosis and repairs above follow n8n’s current documentation for item-linking failures, Code-node pairing, and data relationships through workflow nodes. Merge behavior can vary by selected mode and n8n version, so confirm the UI labels in the instance being debugged.

Frequently asked questions

Does `.first()` fix “Info for expressions missing from previous node”?

It avoids item-link resolution by selecting a position, but it is safe only when that position is the intended record. For row-specific data, restore pairing or use a stable-key lookup.

When should a Code node set `pairedItem`?

When it returns newly constructed output items from multiple incoming items and later nodes need to trace each output to its source. Simple one-input cases are linked automatically.

Does Merge Append combine both branches into one row?

No. Append concatenates the items from its inputs. Use an appropriate Combine mode when the same output row should contain fields from both inputs.

Why does a branch reference show null instead of stopping the execution?

When the current item is from another branch, the expression can resolve to null and the node may continue. Test both branch paths and verify the resulting value explicitly.