Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Firestore] Error: 5 NOT_FOUND when writing data #2623

Closed
tobyL05 opened this issue Jul 9, 2024 · 3 comments
Closed

[Firestore] Error: 5 NOT_FOUND when writing data #2623

tobyL05 opened this issue Jul 9, 2024 · 3 comments

Comments

@tobyL05
Copy link

tobyL05 commented Jul 9, 2024

[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.

  • For issues or feature requests related to the code in this repository
    file a Github issue.
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: macOS Sonoma 14.4.1
  • Firebase SDK version: 12.2.0
  • Firebase Product: Firestore
  • Node.js version: v22.0.0
  • NPM version: 10.8.1

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

I cannot write any data to an empty Cloud Firestore using the Firebase Admin SDK. Trying to write any data results in the following error. The code to write to firestore is located in a POST request endpoint using express.js (4.19.2)

Firestore (7.9.0) 2024-07-09T20:48:58.486Z gmAhV [WriteBatch.commit]: Sending 1 writes
Firestore (7.9.0) 2024-07-09T20:48:58.490Z gmAhV [ClientPool.acquire]: Creating a new client (requiresGrpc: false)
Firestore (7.9.0) 2024-07-09T20:48:58.563Z ##### [clientFactory]: Initialized Firestore GAPIC Client (useFallback: false)
Firestore (7.9.0) 2024-07-09T20:48:58.563Z gmAhV [Firestore.request]: Sending request: {"database":"projects/ubc-pmc-portal/databases/(default)","writes":[{"update":{"name":"projects/ubc-pmc-portal/databases/(default)/documents/users/alovelace","fields":{"first":{"stringValue":"Ada"},"last":{"stringValue":"Lovelace"},"born":{"integerValue":1815}}}}]}
Firestore (7.9.0) 2024-07-09T20:48:58.762Z gmAhV [Firestore.request]: Received error: Error: 5 NOT_FOUND: 
    at callErrorFromStatus (/Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/@grpc/grpc-js/src/call.ts:82:17)
    at Object.onReceiveStatus (/Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/@grpc/grpc-js/src/client.ts:360:55)
    at Object.onReceiveStatus (/Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/@grpc/grpc-js/src/client-interceptors.ts:458:34)
    at Object.onReceiveStatus (/Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/@grpc/grpc-js/src/client-interceptors.ts:419:48)
    at /Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/@grpc/grpc-js/src/resolving-call.ts:163:24
    at processTicksAndRejections (node:internal/process/task_queues:77:11)
for call at
    at ServiceClientImpl.makeUnaryRequest (/Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/@grpc/grpc-js/src/client.ts:325:42)
    at ServiceClientImpl.<anonymous> (/Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/@grpc/grpc-js/src/make-client.ts:189:15)
    at /Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/@google-cloud/firestore/build/src/v1/firestore_client.js:237:29
    at /Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16
    at repeat (/Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/google-gax/build/src/normalCalls/retries.js:80:25)
    at /Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/google-gax/build/src/normalCalls/retries.js:119:13
    at OngoingCallPromise.call (/Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/google-gax/build/src/call.js:67:27)
    at NormalApiCaller.call (/Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js:34:19)
    at /Users/tobs/Desktop/code/PMC/pmc-portal-be/node_modules/google-gax/build/src/createApiCall.js:112:30
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 5,
  details: '',
  metadata: Metadata {
    internalRepr: Map(1) { 'x-debug-tracking-id' => [Array] },
    options: {}
  },
  note: 'Exception occurred in retry method that was not classified as transient'
}

Relevant Code:

credentials JSON looks like this:

{
  "type": "",
  "project_id": "",
  "private_key_id": "",
  "private_key": "",
  "client_email": "",
  "client_id": "",
  "auth_uri": "",
  "token_uri": "",
  "auth_provider_x509_cert_url": "",
  "client_x509_cert_url": "",
  "universe_domain": ""
}

Firebase config:

import { cert, initializeApp, ServiceAccount } from "firebase-admin/app";
import serviceAccount from "../../.secret/pmc-portal-credential.json";
import { Auth, getAuth } from "firebase-admin/auth";
import { Firestore, getFirestore } from "firebase-admin/firestore";
import { firestore } from "firebase-admin";

initializeApp({
  credential: cert(serviceAccount as ServiceAccount),
});

const auth: Auth = getAuth()
const db: Firestore = getFirestore();

firestore.setLogFunction(console.log)

export { auth, db }

Adding data to firestore

import { db } from "../../config/firebase";

const docRef = db.collection('users').doc('alovelace');

await docRef.set({
    first: 'Ada',
    last: 'Lovelace',
    born: 1815
});
@google-oss-bot
Copy link

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

@dandv
Copy link

dandv commented Oct 21, 2024

@tobyL05 I'm running into the same cryptic error. I see you marked this issue as "completed". How did you resolve it?

@tobyL05
Copy link
Author

tobyL05 commented Oct 21, 2024

@tobyL05 I'm running into the same cryptic error. I see you marked this issue as "completed". How did you resolve it?

my solution is here #2563

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants