Document Write

165 views
Skip to first unread message

TushMash

unread,
Mar 4, 2021, 5:50:14 AM3/4/21
to Firebase Google Group
Hello Everyone,
I have been using FireStore for a long time. Since I started firebase firestore, I am using the same code unchanged, but from yesterday, when I am trying to update my DB, my console logs " Uncaught FirebaseError: Function DocumentReference.set() called with invalid data. Unsupported field value: undefined (found in field NAVMTB in document Fund/Status)"

according to the Error logs, there is no problem in my code or something. Is there any solution?

Sam Stern

unread,
Mar 4, 2021, 5:55:07 AM3/4/21
to Firebase Google Group
Hi there,

This behavior has been part of Firestore for a long time, although it has bitten me a few times in the past. Basically it happens when you try to do something like this:

ref.set({
  foo: "bar",
  baz: undefined
});

As you probably know, "undefined" is a bit of a quirk in JavaScript. Most languages just have values or "null" but JS has "undefined" which is not a value, it's more like a signal about the absence of a value. For this reason Firestore is not able to persist this object, as there's no cross-platform way we can represent the "baz" field. If you were to set baz to "null", it would work.

If you really want to just move past this error you can set "ignoreUndefinedProperties: true" in the top-level Firestore settings:
https://firebase.google.com/docs/reference/js/firebase.firestore.Settings#ignoreundefinedproperties

However if this error is new it suggests that something in your code changed and you probably want to investigate which field is undefined before just ignoring it! Otherwise you may end up writing bad data.

- Sam

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/4554245b-de12-49a3-96b6-0f5048606132n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages