Interlooper
Interlooper12mo ago

Get Document > Exists boolean returns undefined

Hello again 😄 I'm trying to check if a document already exists and branch accordingly, but the "Exists" boolean keeps returning "undefined" no matter if the doc does or doesn't actually exist. The node itself does pass the data, but the "Exists" method is broken I think. I'm attaching screenshots for reference. Let me know if you need more details
No description
No description
9 Replies
Interlooper
Interlooper12mo ago
This bug seems to be persistant and can be reproduced every time. It looks like it's a minor but very limiting bug when building logic - Can anyone take a look at this?
Gaurav Chadha
Gaurav Chadha11mo ago
Thanks @Interlooper for bringing this up. I think I've seen someone else also reporting same issue. cc @anish could you please help with the fix?
anish
anish11mo ago
Hey @Interlooper , I have updated the script. So now, if you delete the current 'Get Document' node and add it again from the node explorer, it should probably fix this issue.
Interlooper
Interlooper11mo ago
Thank you @Gaurav Chadha and @anish ! I will test it out. One more kinda important thing I noticed is that Get Field Value node also returns undefined. Reproducible every time and very consistent.
Interlooper
Interlooper11mo ago
@anish I'm still seeing it on new nodes.
No description
Shams
Shams11mo ago
hi @Interlooper, i think there's an issue with updating the existing node from the library but you can update the node yourself for now
import { Firestore } from '@google-cloud/firestore';

export default async function readDocument({ collectionName, id, projectId }) {
const firestore = new Firestore(undefined);

const docRef = firestore.collection(collectionName).doc(id);
const doc = await docRef.get();

if (doc.exists) {
return {
id: doc.id,
data: doc.data(),
exists:doc.exists
};
} else {
return {
id,
exists:doc.exists,
data:null
};
}
}
import { Firestore } from '@google-cloud/firestore';

export default async function readDocument({ collectionName, id, projectId }) {
const firestore = new Firestore(undefined);

const docRef = firestore.collection(collectionName).doc(id);
const doc = await docRef.get();

if (doc.exists) {
return {
id: doc.id,
data: doc.data(),
exists:doc.exists
};
} else {
return {
id,
exists:doc.exists,
data:null
};
}
}
Gaurav Chadha
Gaurav Chadha11mo ago
@Interlooper Could you please also submit a support request from the in-app support form? Also add link to this conversation in the message if you would. It will enable us to take a deep look and make fix. Thanks.
Interlooper
Interlooper11mo ago
I had to remove all "exists" checks from workflow, because they crashed it. I built around the issue, so I don't have workflow to report that uses it. Another crash I had to work around is "GetFieldValue" node. I sincerely hope these will be addreesed on lib level soon, I don't want to manually update getDoc nodes everywhere.
Shams
Shams11mo ago
working on it