n8n - ✅(Solved) Fix Google Cloud Firestore Node: Empty arrays cause API error due to incorrect type coercion in jsonToDocument [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
n8n-io/n8n#28212Fetched 2026-04-09 08:16:05
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
commented ×1cross-referenced ×1labeled ×1mentioned ×1

Error Message

  1. The node fails with the error above

Root Cause

In packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts, the numeric check:

} else if (value !== '' && !isNaN(value as number)) {

incorrectly matches empty arrays due to JavaScript's type coercion behavior.

Fix Action

Fixed

PR fix notes

PR #28213: fix(Google Cloud Firestore Node): Fix empty array serialization in jsonToDocument

Description (problem / solution / changelog)

Summary

The jsonToDocument function in the Google Cloud Firestore node incorrectly serializes empty arrays as { integerValue: [] } instead of { arrayValue: { values: [] } }. This happens because JavaScript's type coercion causes isNaN([]) to return false (since Number([]) evaluates to 0), so empty arrays enter the numeric branch instead of falling through to the array handler.

This fix adds a typeof value !== 'object' guard to the numeric check, ensuring arrays and objects are excluded from the numeric branch and reach their correct handlers.

Related Linear tickets, Github issues, and Community forum posts

Fixes #28212

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)

Changed files

  • packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts (modified, +1/-1)
  • packages/nodes-base/nodes/Google/Firebase/CloudFirestore/__test__/GenericFunctions.test.ts (modified, +4/-0)

Code Example

Invalid JSON payload received. Unknown name "integerValue" at 'writes[0].update.fields[10].value': Proto field is not repeating, cannot start list.

---

} else if (value !== '' && !isNaN(value as number)) {
RAW_BUFFERClick to expand / collapse

Bug Description

The Google Cloud Firestore node fails when creating or updating documents that contain empty array fields. The Firestore API returns:

Invalid JSON payload received. Unknown name "integerValue" at 'writes[0].update.fields[10].value': Proto field is not repeating, cannot start list.

Steps to Reproduce

  1. Create a workflow using the Google Cloud Firestore node
  2. Attempt to create or update a document with a field containing an empty array []
  3. The node fails with the error above

Expected Behavior

Empty arrays should be serialized as { arrayValue: { values: [] } } and accepted by the Firestore API.

Actual Behavior

Empty arrays are incorrectly serialized as { integerValue: [] } because of JavaScript type coercion: Number([]) evaluates to 0, so isNaN([]) returns false. The empty array enters the numeric branch in jsonToDocument instead of the array branch.

Root Cause

In packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts, the numeric check:

} else if (value !== '' && !isNaN(value as number)) {

incorrectly matches empty arrays due to JavaScript's type coercion behavior.

n8n version

Latest master

extent analysis

TL;DR

Update the numeric check in GenericFunctions.ts to correctly handle empty arrays by adding a type check for arrays.

Guidance

  • Identify the problematic line of code in GenericFunctions.ts and update the condition to check if the value is an array using Array.isArray() before checking if it's a number.
  • Verify that the updated code correctly serializes empty arrays as { arrayValue: { values: [] } }.
  • Test the updated workflow with a document containing an empty array field to ensure it creates or updates successfully.
  • Consider adding additional type checks or handling for other edge cases that may be affected by JavaScript's type coercion behavior.

Example

} else if (Array.isArray(value)) {
  // handle array serialization
} else if (value !== '' && !isNaN(value as number) && typeof value !== 'object') {
  // handle numeric serialization
}

Notes

This fix assumes that the issue is solely caused by the incorrect numeric check and that updating this condition will resolve the problem. However, additional testing and verification may be necessary to ensure that other edge cases are not introduced.

Recommendation

Apply the workaround by updating the GenericFunctions.ts file with the corrected numeric check, as this will directly address the root cause of the issue and allow for correct serialization of empty arrays.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

n8n - ✅(Solved) Fix Google Cloud Firestore Node: Empty arrays cause API error due to incorrect type coercion in jsonToDocument [1 pull requests, 1 comments, 2 participants]