Firebase · sdk · fg-0191

Firestore setDoc fails with Unsupported field value: undefined

FirebaseError: Function setDoc() called with invalid data. Unsupported field value: undefined (found in field middleName in document users/abc)

Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100

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 })

Affects: 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

Have your agent know this before it fails

claude mcp add --transport http footgun https://getfootgun.com/api/mcp