Firestore: Function setDoc() called with invalid data. Unsupported field value: undefined
A write contained a field whose value is undefined, which Firestore doesn't accept.
Function setDoc() called with invalid data. Unsupported field value: undefinedUnsupported field value: undefined (found in field)Cannot use "undefined" as a Firestore valueValue for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore valueinvalid-argument undefined Firestore Meaning
Remove undefined fields before writing, replace them with null, or enable ignoreUndefinedProperties: true in the Firestore settings (admin: settings({ignoreUndefinedProperties: true})). Also watch out for nested objects, NaN and custom class instances.
Common causes
- Optional property left undefined
- Form field missing
- Nested object with undefined
- Class instance instead of plain object
- Spread of API data with missing keys
⚡ Quick fix
- Strip
undefinedkeys or usenull - Enable
ignoreUndefinedProperties - Convert class instances to plain objects
Detailed fix by platform
JavaScript
const db = initializeFirestore(app, { ignoreUndefinedProperties: true });
How to diagnose
- Undefined — Present?
- Nested — Checked?
- Setting — ignoreUndefined?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Google Cloud / Firebase
- Container failed to start Cloud Run: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable
- 409: The resource already exists Compute Engine: ERROR: (gcloud.compute.instances.create) Could not fetch resource: The resource 'projects/p/zones/z/instances/vm-1' already exists
- BigQuery: Unrecognized name BigQuery: Syntax error / Unrecognized name: customer_id at [3:8] (Did you mean customerId?)
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026