firebase / firebase-tools-ui

A local-first UI for Firebase Emulator Suite.
https://firebase.googleblog.com/2020/05/local-firebase-emulator-ui.html
Apache License 2.0
269 stars 61 forks source link

Firestore sub-collections with nonexistent parents are not showing in emulator #273

Closed Joebayld closed 3 years ago

Joebayld commented 4 years ago

[REQUIRED] Environment info

firebase-tools: 8.4.0

Platform: macOS 10.15.4

[REQUIRED] Test case

I've found that when having nested collections in Firestore, they don't display on the web interface of the emulator unless parent documents contain data.

[REQUIRED] Steps to reproduce

// create some data in a nested collection without data in the document

db.collection('stripe')
.doc('6tSfMgrOCEOi3kj0IHRivd0ZCgX2')
.collection('subscriptions')
.doc('sub_123456789').set({
    status: "active"
})

[REQUIRED] Expected behavior

On the production version of the data viewer, it displays empty documents in italics (to designate that there is no fields but sub-collections exist). Image below.

Screen Shot 2020-05-24 at 8 02 36 PM

[REQUIRED] Actual behavior

There is nothing to display on the UI and I cannot access child collections. If I set some dummy data on a document, the row will appear.

samtstern commented 4 years ago

@Joebayld thanks for filing this. Since it's about the Emulator UI I'm gonna move it over to that repo.

4mitabh commented 4 years ago

This is not merely an emulator UI issue.

In certain cases, the behavior of writes is different between emulators and production.

Steps to reproduce:

Perform the following write operation, on em empty database.

db.collection('one')
.doc('two')
.collection('three')
.doc('four').set({
    status: "active"
})

Expected behavior

  1. An empty document 'two., with a collection 'three' is created. This works perfectly in production.
  2. Reads to path "/one/two" should succeed .

Actual behavior:

  1. Document 'two' is not created in the emulated database.
  2. Reads to path "/one/two" fail. Document.exists returns false.
yuchenshi commented 4 years ago

@4mitabh Just let me clarify: Even in production, the document two is not automatically created either. Reads to two always fail since two does not actually exist. There is no automatic cascading creation or deletion in Firestore.

The Firebase Console in production however shows an entry of "two" in the data viewer to help you navigate the database and find things under it. If you look closely, it also says "this document does not exist" in the panels to help clarify. This issue tracks the implementation of a similar feature to show a placeholder for such missing links in the Emulator UI.

4mitabh commented 4 years ago

I see. Thanks @yuchenshi for the clarification.

yuchenshi commented 4 years ago

I've escalated this internally as b/152785133 and we're actively trying to staff this fix. In the meantime, feel free to send us a Pull Request.

tjlav5 commented 4 years ago

345 only partially addresses this... we can now navigate to a document whose parent(s) does not exist. Still need to add functionality to show the list of "missing docs" in italics in the UI-list.

phenry20 commented 3 years ago

Any Updates?

edmondklai commented 3 years ago

I have an issue maybe related to this, when the document is empty and there is a sub-collection of documents. I tried using the UI to add fields to the parent document.

I get this error in the console.

Uncaught (in promise) Error: .set() on an existing document would delete other fields
    at api.tsx:51
    at c (runtime.js:63)
    at Generator._invoke (runtime.js:293)
    at Generator.next (runtime.js:118)
    at r (asyncToGenerator.js:3)
    at s (asyncToGenerator.js:25)
yuchenshi commented 3 years ago

@phenry20 This should be fixed now. If you see otherwise, make sure to upgrade to the latest CLI and try again, and feel free to open a new bug if it still doesn't work for you.

@edmondklai I'm afraid you ran into a separate issue, #437. If you can reliably reproduce the issue, please add a comment there. Thanks!

28JayG commented 2 years ago

I am still facing this issue

FrancescoBurchielli commented 2 years ago

hi everyone, any update on this? I do still face this issue now in May 2022, with latest Firebase CLI on Windows

mozeryansky commented 2 years ago

hi everyone, any update on this? I do still face this issue now in May 2022, with latest Firebase CLI on Windows

Use Supabase. It's 100000x better.

johnberang12 commented 2 years ago

im having the same issue..icant write on a subcollection but works perfectly on the actual firestore..whats the update on this.?

johnberang12 commented 2 years ago

why is this marked as solved then the issue is still not resolved

braadworst commented 1 year ago

Is this being looked at? I am still experiencing this issue 01-08-2023

mozeryansky commented 1 year ago

@braadworst I recommend switching to Supabase. No one should be using Firebase, it's just bad software.

braadworst commented 1 year ago

Supabase

Why blasting your commercial interests in a Github thread? Furthermore, Firebase ain't bad software and if I was ever considering Supabase your behavior has made me put it on the bottom of the list

mozeryansky commented 1 year ago

@braadworst I don't have any commercial interest, I was giving a recommendation. I noticed that you are commenting on a 3-year-old bug that I once had, which is closed, yet you still have the same issue.

The reason Firebase is bad software is because they don't fix their bugs. Instead of going through all this trouble, as I and many others have experienced before, I highly recommend trying an alternative that actually works. It's entirely your choice whether you want to continue to use Firebase and resubmit issues.

braadworst commented 1 year ago

So anyone having this problem, if you have a : in your id, the sub collections will not show in the emulator. There might be more special characters that trigger this behavior, so look for that in your ids. This sorts it out for me, everything works well, emulator shows the sub collections. 👍

pepoospina commented 2 months ago

Why is this issue closed?

mozeryansky commented 2 months ago

Why is this issue closed?

Why are you using Firebase when there are so many better alternatives?

Firebase appears to just be in maintenance mode for a long time now, scroll up and see they don't care. Search the closed issues and you'll see they never resolve them. I've made numerous posts on SO where they used to respond, but they just say "that's how it works" and I'm pretty sure that guy in charge of that left years ago. Save yourself the headache. And before @braadworst gets into a pithy again, just know I have a personal interest in helping my fellow software engineers write better code, because one day I may end up using your product.