Guides / n8n

Why your fields disappear in n8n, and how to keep them

Intermediate, 8 min read,

You set a field three nodes ago. Now it's undefined, and the data looks wrong. It almost never is. In n8n, fields go missing for four reasons, and each one has a clean fix.

The example uses JSONPlaceholder, a free fake API, so you can rebuild every step without an account: fetch a few posts, then fetch each post's author.

Manual TriggerStart
HTTP RequestGet posts
HTTP RequestGet author
CodeCombine

Set up the example

  1. Get posts: HTTP Request, GET https://jsonplaceholder.typicode.com/posts?_limit=3. The answer is a list, so n8n turns it into three items, each with id, userId, title and body.
  2. Get author: HTTP Request, GET https://jsonplaceholder.typicode.com/users/{{ $json.userId }}. It runs once per post.

Run it and open Get author's output. The authors are there. The post titles are gone.

Cause 1: the node only outputs its own result

HTTP Request, Google Docs, Google Drive and most app nodes replace each item with what they fetched. Whatever came in is not passed along. This is the most common cause by far, and it looks exactly like a data problem.

Fix: bring the earlier data back right after the node. Add a Code node, Combine, in Run Once for All Items mode:

return $input.all().map((item, i) => {
  const post = $('Get posts').itemMatching(i).json; // the post that produced this author
  const author = item.json;

  return {
    json: {
      postId: post.id,
      title: post.title,
      authorId: author.id,
      authorName: author.name,
      authorEmail: author.email,
    },
  };
});

itemMatching(i) follows n8n's item links back to the item in Get posts that produced item i here. It doesn't rely on the order of a list, so it stays right even if an earlier node skipped an item.

No code? A Merge node does the same: connect Get posts to input 1 and Get author to input 2, set Mode to Combine and Combine By to Matching Fields, matching userId in input 1 to id in input 2. Then read cause 2 before you trust the result.

Cause 2: two objects, one field name

Posts and authors both have an id. Combine them the quick way and one silently overwrites the other:

const merged = { ...post, ...author };
// merged.id is now the author's id. The post's id is gone, with no error.

The Merge node does the same by default: when field values clash, input 2 wins. And it isn't only id. Two APIs can both send name, status or createdAt, meaning different things.

Fix: never spread two API objects into one. Pick each field and give it a name that says where it came from, as the Combine code above does: postId, authorId. In a Merge node, open Options, then Clash Handling, and choose Always Add Input Number to Field Names, so both versions survive.

Cause 3: your own code reshaped the item

A Code node returns exactly what you build, nothing more. Building a fresh object to add one field drops every other field:

// Meant to add a flag. Actually keeps only two fields.
return $input.all().map(item => ({
  json: { id: item.json.id, isLong: item.json.body.length > 150 },
}));

The sneakier version sits in the middle of the code: a .map() that keeps only the fields one step needed, long before the return you're staring at.

Fix: when you mean to add, start from the original item:

return $input.all().map(item => ({
  json: { ...item.json, isLong: item.json.body.length > 150 },
}));

When you really want a slim item, slim it once, at the end, on purpose. Every step that needs a field later then still has it.

Cause 4: reading the wrapper instead of the data

Every n8n item is wrapped: { json: { ... } }. When you read items in a Code node, the fields sit one level down:

$input.all().map(item => item.title);      // undefined for every item
$input.all().map(item => item.json.title); // the titles

The output side is forgiving: a Code node adds the json wrapper for you if you leave it out. The input side never is.

A related trap: a Code node in Run Once for All Items mode that returns a single object turns ten items into one. If the item count drops, check the mode first.

Find the node that dropped it

  1. Open the execution and click through the nodes from the start. Find the first node whose output no longer has the field.
  2. Is it an app or HTTP Request node? Cause 1.
  3. Did the field come back with a different value? Cause 2.
  4. Is it a Code node? Read every transform in it, not just the return. Cause 3 or 4.

The traps around it

Why it's built this way