How to Fix “Paired Item Data Is Unavailable” in n8n
Trace a broken item link in n8n and keep each output linked to the right source row after sorting or filtering.
When n8n says “Paired item data is unavailable,” check how the current item is linked to earlier nodes. An expression such as `$('Read Orders').item.json.orderId` asks for the earlier row associated with this specific item. Seeing an order ID in the earlier node’s output only confirms that the field exists somewhere in that output.
Find the first node that breaks the link
- Open the failing execution and identify the exact expression and referenced node. If the value already exists in the current input, read it with `$json` and check the resulting value for each row.
- If you need the earlier node, follow the path between it and the failing expression. Inspect nodes that create, filter, sort or combine records. Compare their inputs and outputs for the same execution. An error about several matching items requires a decision about which record to use. An unavailable link calls for restoring the relationship or carrying the value forward.
- In a Code node that constructs new items, preserve the input index when the relationship is known. In **Run Once for All Items**, capture the original index before filtering or sorting. If you store only the position after sorting, a downstream expression may resolve to the wrong source row.
- Test with at least two distinct IDs and inspect every result. A one-item test can look correct even if the workflow always picks the first row. Use a harmless copy or disable external writes while checking your mapping.
Fictional example: keep the original row after sorting
Suppose a Code node sorts two order records by amount before a later node needs their original order IDs. Tag each output with its original input index:
const indexed = $input.all().map((item, index) => ({ item, index }));
indexed.sort((a, b) => b.item.json.amount - a.item.json.amount);
return indexed.map(({ item, index }) => ({
json: { amount: item.json.amount },
pairedItem: { item: index },
}));This example assumes one input stream and numeric amounts. If the higher-value order moves to the first position, it should still resolve to its own original order ID. You can also include the order ID directly in the output when downstream steps simply need that field.
Questions people ask
Is replacing .item with .first() safe?
Use the first item when it really is a shared value, such as a single settings record. When every order has its own ID, taking the first item can silently assign the first order’s ID to later records.
What if I combine several rows into one summary?
Give the summary an explicit grouping key and include the fields it needs. If you need to show which rows contributed, carry their IDs in an array. A summary can have several contributing inputs, so a downstream lookup for one uniquely paired source may be ambiguous.
Why did the workflow pass with pinned data?
The pinned sample may contain only one record or preserve an order that live data does not. Compare a two-record test with a sanitized sample that exercises the same filter or sort. Use the actual failed execution to check where the data diverged.