Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

firestore document id duplication error(error for id to be duplicated in firestore)

Hi, I'm firestore developer. I accessed firestore collection(users collection->user.id  document-> feeds collection) to create doc in that(feeds) collection and I checked console. then same document with id(user.id ) is there. why so? To solve this(to correctly access document), how can I do?

Solved Solved
0 2 932
1 ACCEPTED SOLUTION

There are a few possible reasons why you might be getting a Firestore document ID duplication error, even though you have checked the console and seen that a document with the same ID does not exist.

One possibility is that you are trying to create a document with an ID that has been used in the past and deleted. Firestore allows you to reuse document IDs of deleted documents immediately.

It's also possible that there's a bug in the Firestore client library you're using. If you're confident that you're not trying to create a document with an ID that's already in use, and you've checked the console to confirm that a document with the same ID doesn't exist, then you might consider reaching out to the library's developers or checking for updates.

To solve this problem and correctly access the document, you can:

  • Ensure you're creating a document in the correct collection and subcollection.
  • If you're trying to create a document with an ID that you suspect might be causing issues, consider using a different ID.
  • Clear any caches or check for updates in the Firestore client library you're using.

View solution in original post

2 REPLIES 2

There are a few possible reasons why you might be getting a Firestore document ID duplication error, even though you have checked the console and seen that a document with the same ID does not exist.

One possibility is that you are trying to create a document with an ID that has been used in the past and deleted. Firestore allows you to reuse document IDs of deleted documents immediately.

It's also possible that there's a bug in the Firestore client library you're using. If you're confident that you're not trying to create a document with an ID that's already in use, and you've checked the console to confirm that a document with the same ID doesn't exist, then you might consider reaching out to the library's developers or checking for updates.

To solve this problem and correctly access the document, you can:

  • Ensure you're creating a document in the correct collection and subcollection.
  • If you're trying to create a document with an ID that you suspect might be causing issues, consider using a different ID.
  • Clear any caches or check for updates in the Firestore client library you're using.

Thank you for your reply. but I solved this. the problem is that there is a space in front of ID. haha. It's my mistake. Thank you.