Skip to content

Firestore errorFirestore: “Function addDoc() called with invalid data. Unsupported field value: undefined”

“Unsupported field value: undefined” is a Firestore SDK error for a write that includes a field set to undefined, which Firestore can’t store. The message names the field. Remove it, save null instead, or tell the SDK to skip undefined fields.

Short answer

Read the field name in the error, usually after “found in field”. Then find why it is undefined, often an optional form input or a missing API value. Leave the field out when it has no value, save null if you want an empty value stored, or set ignoreUndefinedProperties: true when you set up Firestore.

Rather not fix it yourself? App Fix Ticket starts with a fixed-price diagnosis, then a fixed price for the fix before any fix work.

Why the field is undefined, and the fix

  1. 01

    An optional field has no value

    “If set to false or omitted, the SDK throws an exception when it encounters properties of type undefined.” Firebase, FirestoreSettings.ignoreUndefinedProperties

    One undefined field makes the SDK refuse the whole write. setDoc and updateDoc refuse it the same way. In the Admin SDK the message reads “Cannot use undefined as a Firestore value”.

  2. 02

    Leave out empty fields before saving

    Strip undefined values from the object, or set the ones you want stored to null. This helper handles top-level fields only, so clean nested objects too if you have them.

    const clean = Object.fromEntries(
      Object.entries(data).filter(([, v]) => v !== undefined),
    );
    await addDoc(collection(db, 'orders'), clean);
  3. 03

    Let the SDK skip them

    “If set to true, these properties are skipped and not written to Firestore.” Firebase, FirestoreSettings.ignoreUndefinedProperties

    Set the option once, before any other Firestore call, or initializeFirestore throws because Firestore already started. Test it with your data shape, since undefined values inside arrays may not be skipped.

    import { initializeFirestore } from 'firebase/firestore';
    
    const db = initializeFirestore(app, { ignoreUndefinedProperties: true });
    
    // Admin SDK (Node), before the first read or write
    // import { getFirestore } from 'firebase-admin/firestore';
    // getFirestore().settings({ ignoreUndefinedProperties: true });
  4. 04

    The value really should be there

    If the field must exist, skipping it hides a bug. Check the source: a typo in a property name, a value read before it loaded, or an API response missing a key.

Checked against the vendor’s docs on : Firebase reference: FirestoreSettings.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
A buyer in the United States, July 2022. Shopify on Fiverr
All 127 Fiverr reviews

Related: Firestore ALREADY_EXISTS · Firebase “Missing or insufficient permissions” · Firestore query requires an index · Firebase Storage object-not-found

Questions

More on this error

Is null the same as leaving the field out?

No. null stores the field with an empty value, so queries on that field can match it. Leaving it out stores no field at all.

Does the option change existing documents?

No. It only affects writes made after you set it. Fields already saved stay as they are.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.