TECHNOLOGY

n8n pairedItem preserves the source of a transformed document result

In this article
THE QUICK TAKE

Item lineage records which input produced a result; selecting the first item can hide a broken relationship while attaching the wrong source to an answer.

Keep source identity through transformation

A workflow extracts passages from several documents and creates new summary items. Later it needs each summary’s original URL. Matching by the current list position is fragile after filtering or sorting. n8n’s item-linking concepts describe metadata connecting outputs to their generating inputs. Preserve that relationship alongside the content so a correct summary does not acquire a neighboring document’s citation.

Know when automatic linking is insufficient

n8n can infer many ordinary input/output relationships, but creating new items from multiple inputs can leave provenance unknown. The Code-node linking guide requires pairedItem in relevant cases when later expressions use a previous node’s .item. Returning a new JSON object with the right visible fields does not by itself retain the hidden relationship. Trace the transformation that first created the unlinked result.

Represent the real relationship

When a new result derives from a particular input, preserve that source association. When a summary combines several documents, a singular source may be conceptually wrong; retain a source set or another explicit mapping appropriate to the task. Do not manufacture a single-item lineage merely to silence an expression error. The workflow must express what produced the content, rather than choose whichever source makes the downstream field nonempty.

Diagnose the error category before substituting position

The linking-error guide distinguishes a broken thread, multiple matching items, and a node on another branch. A cross-branch reference can resolve to null while execution still succeeds. .first() or indexed access is appropriate only when the intended source is genuinely positional. Replacing every failed .item with .first() can produce clean runs that consistently cite the wrong document, especially after an append-style merge.

Test provenance as part of answer quality

Use documents with unmistakably different URLs and facts, then reorder and filter them before the summary stage. Inspect both the passage and attributed source. The citation-support guide makes clear why plausible text with a wrong reference fails the evidence requirement. Tool observations distinguish a successful node from correct lineage. Preserve a case that checks attribution after transformation so later refactoring cannot quietly break source tracking.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles