Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

410
Views
Exception from a finished function: Error: There is no user record corresponding to the provided identifier

This firebase function keeps track data changes of a firestore collection and push it to the Existing contact of a CRM.

// LISTENER
exports.listenData = functions.https.onRequest(async(request, response) => {

  // Keep track of profile collection
  db.collection('profile').onSnapshot(async(querySnapshot) => {
    console.log('change in profile');

    let changedDocs = querySnapshot.docChanges();
    for (let i = 0; i < changedDocs.length; i++) {
      let change = changedDocs[i];

      if (!change.doc.exists) {
        continue;
      }
      console.log('change in profile in loop');

      let profileDocData = change.doc.data();
      let body = {
        "customField": {
          "subscription_expiration_date": ""
        }
      };

      let user = await admin.auth().getUser(change.doc.id);

      // profile
      try {
        body.customField.subscription_expiration_date = profileDocData.expiration_date;
      } catch (error) {
        body.customField.subscription_expiration_date = '';
      }

      console.log("Profile changed by " + user.email ? ? "Unknown");

      try {
        let res = await axios.get('EndPoint URL ?email=' + user.email, {
          headers: {
            "Authorization": "Bearer Token"
          }
        });

        let userId = res.data.contacts[0].id;
        axios.put('EndPoint URL /contacts/' + userId, body, {
          headers: {
            "Authorization": "Bearer Token"
          }
        });

      } catch (error) {
        console.log('Error on profile');
      }
    }
  });


  response.send("Listening...");
});

Output:

Screenshot of Console

Error

Exception from a finished function: Error: There is no user record corresponding to the provided identifier.

I'm confused here! Anyone?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

First of all, when you send a response back to the client, the function is closed (that's why you get "a finished function"). So, if you want to monitor changes, you should set up a trigger: https://firebase.google.com/docs/functions/firestore-events.

The error itself says there is no user in the Firebase Authentication section with the id you are providing the admin.auth().getUser with.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!