Firestore Get document with field type reference

Describe the problem/error/question

I have basic action that retrieves user document based on document id.
If the document containts field type reference to other document in Firestore, I cant use simplify option for the output.

It works without simplifying however it requires additional actions

If the document doesnt have field doc_ref (reference to other document in Firestore) everything works fine.

image

Switching Simplify results in below error.

ERROR: Maximum call stack size exceeded

Stack

RangeError: Maximum call stack size exceeded
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:97:16
    at Array.find (<anonymous>)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:97:11)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)
    at documentToJson (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Firebase/CloudFirestore/GenericFunctions.js:120:27)

I do not include the workflow as its only one step and requires Firebase set up.

Information on your n8n setup

  • n8n version: current n8n.cloud version
  • Database (default: SQLite): n/a
  • n8n EXECUTIONS_PROCESS setting (default: own, main): n/a
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system: n/a

Hi @J4ke, welcome to the community.

I am so sorry to hear the Simplify option doesn’t work in your case. Seeing the non-simplified version works for you, I assume you don’t need a workaround but instead wanted to report this problem? I’ll make sure to add it to our bug tracker for a closer look.

Hi,

I build query to retrieve only the fields I need, therefore avoiding this issue.

Just out of curiosity and maybe for other people encountering it. Is there simple way how to convert the raw output to better json object? Is there any node that can do it or would I have to make a custom code?

Thank you

J4ke

Hi @J4ke, the Set node would be the easiest way to reformat a dataset in n8n. For example, if I only want to get the user reference and timestamp from my orders collection, I could do something like this:

Subsequently I could then resolve the reference itself via another Firestore node:

The values I am using here are expressions. You can build them using either drag and drop from the input fields on the left, or by manually writing them (that’s what I in order to build {{ $json.user.split('/')[6] }} to extract the user ID from the reference for example).

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.