Closed sr5434 closed 3 months ago
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Did you enable Firestore from the Firebase console? I have seen this error before when Firestore is not properly set up from the console.
When I create a firebase app instead of using a service account it works sometimes
@lahirumaramba @sr5434 I am also experiencing this issue.
I have two projects, one for development and one for production, and I am initializing Firestore using a service account. The development project does not have this issue. However, when I set up the production project yesterday, the problem occurred. (BTW, the same problem occurs in the production project, even in the emulator environment.) We have confirmed that the correct service account for the project is being loaded.
Here are the details:
// package.json
{
"engines": {
"node": "18"
},
"dependencies": {
"firebase-admin": "^11.11.1",
"firebase-functions": "^5.0.1"
}
}
// firebaseConfig.js
const admin = require("firebase-admin");
require("dotenv").config({ path: `.env.${process.env.NODE_ENV}` });
const serviceAccount = require(process.env.SERVICE_ACCOUNT_KEY);
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
console.log(serviceAccount);
const db = admin.firestore();
module.exports = { db };
I found the same information and wanted to share it for your reference: https://ja.stackoverflow.com/questions/99288/node-js-%e3%81%a7-gcp-%e3%81%ae-cloud-functions-%e3%81%8b%e3%82%89-firestore-%e3%81% ae%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95%e3%81%8c%e5%88%86%e3%81%8b%e3%82%89%e 3%81%aa%e3%81%84
Thank you for reading!
Additionally, I conducted further investigations and would like to report the findings for your reference.
Firstly, regarding the Firestore activation, I was able to manually add data from the console screen, so I believe Firestore has been successfully activated.
Next, I tried the recommended method from the official documentation as follows, but the error situation remains the same.
const { getFirestore } = require("firebase-admin/firestore");
const { initializeApp } = require("firebase-admin/app");
const app = initializeApp();
console.log("initializeApp", app);
const db = getFirestore();
console.log("getFirestore", db);
module.exports = { db };
I have two projects, one for development and one for production, and I am initializing Firestore using a service account. The development project does not have this issue. However, when I set up the production project yesterday, the problem occurred.
Did you follow the same steps to generate both service accounts and were they generated on the Firebase Console?
Yes, I believe I followed the same steps. I created both of these projects at the same time about a month ago. I issued the service account key for the production project a few days ago.
I'll take a look at this tomorrow. For now, do you have some log output showing the entire stack trace and error message that you could post?
I was able to get the code working when I used the Firebase NPM package on the backend and created a web app in the firebase console.
Is your problem solved?
Yes
The production project required a specified database ID. The issue is resolved. Thank you!
Hello @sr5434 and @caravelle-inc
I was able to get the code working when I used the Firebase NPM package on the backend and created a web app in the firebase console.
The production project required a specified database ID. The issue is resolved. Thank you!
I'm stuck with the same problem. Can you provide the full steps of what solved your problem? if it isn't a bother I will appreciate to see your package.json
, firebaseConfig.js/ts
and also the calling for the collection
, for example: a simple get()
to get all documents of a collection.
I'm also facing the same problem, could someone share what they did to resolve it?
currently i am using debian 12 Here's the workflow:
I created a project in google cloud platform. I went to Firebase, created a Firebase project, and then set up Cloud Fire store. I navigated to the google cloud platform service account and selected fire base-admin@xyz since it was the only available option. I created a json file key for this service account. In Node-RED, I used the Firestore out node and entered the credentials in the admin config. However, I'm encountering an "Error 5: Not Found" message, and I don't understand why it's not working. the Firebase project is base on the project id of google cloud platform i had created earlier
i want to connect my node-red firestore out to firestore , and add some data to my collection. and i created my database on production mode.
I'm getting the exact same error whenever I try to read/write to cloud firestore. Even after following the docs exactly.
For anyone experiencing this issue, please open a new issue with the specifics of your scenario.
@dconeybe Hello, I experienced this issue nowadays and I realized that I deleted '(default)' named database. If you have not this default, you cannot access another one, I know this is stupid but when I re-created a database with '(default)' name and use it, the error resolved :) I hope this was helpful.
Thanks for the info, @ugursirmen. We'll look into the effects of deleting the default database.
I managed to solve this issue by adding my database id to getFirestore() like so getFirestore(<database_id>)
. I didn't realize/forgot that I set my own custom database id in the Firebase Console when I created my database nor did I realize that the database id was there on the console the whole time.
Note: I've opened a ticket to get the error message fixed to include the name of the database that was "not found" (Googlers can see details in b/354018499).
I managed to solve this issue by adding my database id to getFirestore() like so
getFirestore(<database_id>)
. I didn't realize/forgot that I set my own custom database id in the Firebase Console when I created my database nor did I realize that the database id was there on the console the whole time.
this works fine for me thanks
firebaseConfig
thanks , it worked only in that way
thanks
[READ] Step 1: Are you in the right place?
Cloud Firestore support is provided by the
@google-cloud/firestore
library. Therefore the easiest and most efficient way to get Firestore issues resolved is by directly reporting them at the nodejs-firestore GitHub repo.If you still think the problem is related to the code in this repository, then read on.
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
When I call the API Route, instead of creating a new user in Firestore, I get a vague "Error: 5 NOT_FOUND" error message with no additional details. I have used this code before in other projects and can confirm that it used to work.
Relevant Code:
The following is a NextJS API Route I used.