Firestore Emulator allowing two documents with same ID.
See original GitHub issueThe firestore emulator is allowing two documents with the same ID to be added in a collection. (I have attached the screenshot).
The original document was imported while starting the emulator. When I tried to fetch the document in my web app (React), the “doc.exists” property was false.
I created a new document with the same ID (keeping the old one there) and it allowed me to create a new document. Also, I was able to fetch the newly created document.
[REQUIRED] Environment info
firebase-tools: 8.6.0
Platform: macOS
[REQUIRED] Test case
Creating two documents in Firestore Emulator with the same ID. One of the documents was imported from a previous export. The other was created on the Emulator UI (on Google Chrome).
[REQUIRED] Steps to reproduce
- Start the emulator (new, fresh version).
- Create a test document with a specific ID in a collection.
- Export the data (using export flag) and close it.
- Start the emulator again, but this time importing the previously exported data.
- Try fetching (reading) the old document on a web application (doc.exists will be false)
- Add a new document in the same collection with the same ID.
- Try fetching (reading) the document again, this time it succeeds.
[REQUIRED] Expected behavior
- New document with same ID should not be allowed in the same collection.
- It should be possible to fetch an already existing document from a previous import.
[REQUIRED] Actual behavior
- New document with same ID was created using the Emulator UI.
- Old document wasn’t being read (doc.exists = false) on running the “get()” method on a web application. New document was successfully read from the Firestore database once created.

Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Firestore allows the creation of two separate documents ...
1 Answer 1 · 1 · Well it is not allowed for endusers. · There is absolutely no need to hand-create a document...
Read more >Connect your app to the Cloud Firestore Emulator - Firebase
Note: It's generally a good practice to use one project ID for all emulator invocations, so the Emulator Suite UI, different product emulators,...
Read more >Testing security rules | Firestore
Firestore Security Rules include two pieces: A match statement that identifies documents in your database. An allow expression that controls access to those ......
Read more >Firestore: Copy Data from Prod to Dev or Emulator | by Mathis
This feature also allows you to duplicate data within the same project. ... will be overwritten when they share the same document ID....
Read more >JavaScript & Firebase - Firestore and Auth - YouTube
In this video, David East is going to show how to use Firestore and Firebase Authentication together to build a secure, real-time, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, My comment has nothing to do with the firebase Emulator.
I just wanted to mention when I create a new document in Cloud Firestore manually using the firebase console with an id ID1, I can then create programatically using the javascript SDK (batch.set) a second document with the same ID1.
I create a document reference to the first document manually created with an auto-generated id ID1. I then batch.set() this document reference with an object. It will then not update the first document manually created, it will instead create a new document with the same id ID1.
Sorry for the slow reply - this is being tracked internally as b/163146117