firebase / firebase-admin-python

Firebase Admin Python SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
1.02k stars 309 forks source link

firestore data doesn't show in emulator UI #802

Open shanzhengliu opened 4 weeks ago

shanzhengliu commented 4 weeks ago

[READ] Step 1: Are you in the right place?

I have run the simple test code

import os
import firebase_admin
from firebase_admin import credentials, firestore

os.environ['FIRESTORE_EMULATOR_HOST'] = 'localhost:10000'  

cred = credentials.Certificate("credential.json") 
firebase_admin.initialize_app(cred)

db = firestore.client()

def test_firestore():

    collection_name = "test_collection"
    document_id = "test_document"

    data = {
        "name": "Test User",
        "age": 30,
        "status": "active"
    }

    try:

        doc_ref = db.collection(collection_name).document(document_id)
        doc_ref.set(data)
        print("Data successfully written to Firestore.")

        doc = doc_ref.get()
        if doc.exists:
            print("Document data:", doc.to_dict())
        else:
            print("No such document!")

    except Exception as e:
        print(f"Error interacting with Firestore: {e}")

if __name__ == "__main__":
    test_firestore()

I can get the log

Data successfully written to Firestore.
Document data: {'age': 30, 'status': 'active', 'name': 'Test User'}

However, the data doesn't shows up in the emulator ui

image

[REQUIRED] Step 2: Describe your environment

In this case I can confirm the data have saved successfully and can get via code but it doesn't shows up in emulator, would you like have a look? thanks

this is my firestore rule

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}
image

this is my emulator log

google-oss-bot commented 4 weeks ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.