Firebase · sdk · fg-0191

Firestore setDoc fails with Unsupported field value: undefined

If you see FirebaseError: Function setDoc() called with invalid data. Unsupported field value: undefined (found in field middleName in document users/abc), the cause and the fix for Firebase are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
FirebaseError: Function setDoc() called with invalid data. Unsupported field value: undefined (found in field middleName in document users/abc)Same error from updateDoc and addDocFails only when an optional form field is left empty
Cause
The SDK throws on any property set to undefined unless the Firestore instance was created with ignoreUndefinedProperties. The default is to throw.
Fix
Initialize Firestore with ignoreUndefinedProperties true, or strip undefined fields before writing. Use null when you want the field stored as empty.
Apply
import { initializeFirestore } from 'firebase/firestore'; const db = initializeFirestore(app, { ignoreUndefinedProperties: true }); // firebase-admin: getFirestore().settings({ ignoreUndefinedProperties: true })
Affected
Every Firebase JS SDK version and firebase-admin Firestore throw by default; the ignoreUndefinedProperties setting exists since @firebase/firestore 1.14.6 (mid-2020)
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun