#39784·n8n

Google Sheets node evaluates Document and Sheet for the first input item only

Author: AsifMahsudCreated Sep 28, 2026Updated Sep 28, 2026
Labelsteam:nodesstatus:in-linearstatus:team-assigned

Bug Description

In the Google Sheets node (v2, node versions 4.x), the Document and Sheet resource locators are evaluated once, against the first input item only. Every other parameter of the operation (options, filters, range, columns) is evaluated per item.

So when the Sheet field is an expression like {{ $json.sheet }} and the node receives several items, the node silently uses item 0's sheet for all of them. For Get Row(s) on node versions > 4.1, the node loops over the input items (one read per item) but every iteration reads the same tab. There is no error and no execution hint, so the wrong data goes downstream unnoticed. The expression editor preview shows the per-item values correctly, which makes this harder to spot.

Root cause (same code on master and on the 2.39.10 tag):

This keeps coming up on the forum, where it is answered with workarounds (Split Out, Loop Over Items with batch size 1, Switch per sheet) rather than reported:

To Reproduce

  1. Take a spreadsheet with two tabs that have different columns, e.g. Channels Data (16 rows) and Posts Log (188 rows).
  2. Build: Manual Trigger → Code node returning two items { sheet: 'Channels Data' } and { sheet: 'Posts Log' } → Google Sheets Get Row(s), Document by ID, Sheet By Name = {{ $json.sheet }}.
  3. Execute.

Result on n8n 2.39.10, tested with node versions 4.5 and 4.6:

Input items (in order) Output items Rows came from
Channels Data, Posts Log 32 Channels Data only (16 rows, read twice)
Posts Log, Channels Data 376 Posts Log only (188 rows, read twice)

Swapping the order of the two input items changes which tab is read, and the second item's tab is never read in either case.

Workflow (replace the document ID and credential):

json
{
  "nodes": [
    { "parameters": {}, "name": "When clicking ‘Execute workflow’", "type": "n8n-nodes-base.manualTrigger", "typeVersion": 1, "position": [0, 0] },
    { "parameters": { "jsCode": "return [{ json: { sheet: 'Channels Data' } }, { json: { sheet: 'Posts Log' } }];" }, "name": "Emit sheet names", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [220, 0] },
    { "parameters": { "documentId": { "__rl": true, "mode": "id", "value": "YOUR_SPREADSHEET_ID" }, "sheetName": { "__rl": true, "mode": "name", "value": "={{ $json.sheet }}" }, "options": {} }, "name": "Get rows", "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.6, "position": [440, 0], "credentials": { "googleSheetsOAuth2Api": { "id": "YOUR_CREDENTIAL_ID", "name": "Google Sheets account" } } }
  ],
  "connections": {
    "When clicking ‘Execute workflow’": { "main": [[{ "node": "Emit sheet names", "type": "main", "index": 0 }]] },
    "Emit sheet names": { "main": [[{ "node": "Get rows", "type": "main", "index": 0 }]] }
  }
}

Expected behavior

Document and Sheet should be resolved per input item like the other parameters, so the run above returns 16 rows from Channels Data followed by 188 rows from Posts Log (204 items), with paired items pointing at the right source. Same for Append, Update, Append or Update, Delete and Clear, which all go through the same router.

If per-item resolution is considered a breaking change that needs a new node version, a fallback would be to at least fail or add an execution hint when the Document or Sheet expression evaluates to different values across the input items, instead of silently using the first one.

Happy to open a PR for this if the approach is agreed.

Debug Info

Copied from a self-hosted instance (Help > About n8n is not reachable from the API, so the relevant fields are listed here):

  • n8n version: 2.39.10, self hosted
  • Google Sheets node versions tested: 4.5 and 4.6; the code path is unchanged on master (4.7)
  • Credential type: Google Sheets OAuth2
  • Execution triggered via webhook (production mode); the manual-trigger version behaves the same

Operating System

Linux (AWS EC2)

n8n Version

2.39.10

Node.js Version

Not checked (release build of 2.39.10); the behaviour is in the node code and does not depend on it

Database

Not checked; does not affect this node's behaviour

Execution mode

Not checked; does not affect this node's behaviour

Hosting

self hosted