TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type number with Firebase Admin

I’m using firebase-admin to retrieve data and using Netlify Lambda functions to call the service. This is basically it.

Here is my code:

exports.handler = (event, context, callback) => {
  const { id = "toronto" } = event.queryStringParameters;
  const cityRefs = dbInstance.collection("cities");
  console.log("req.params.id", id);

  if (id === "mumbai") {
    console.log("in here", id);
    let cityRef = cityRefs.doc("id1");
    return cityRef
      .get()
      .then(doc => {
        if (!doc.exists) {
          console.log("No such document!");
        } else {
          console.log("Document data:", doc.data());
          callback(null, {
            statusCode: 200,
            body: doc.data()
          });
        }
      })
      .catch(err => {
        console.log("Error getting document", err);
        callback(err);
      });
    }

}

I keep getting the below error. I’m not exactly sure I’m doing wrong.

Function invocation failed: TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received type number

I see the console.log(“in here”, id); but it goes in the catch block and I get console.log("Error getting document", err);

Hi, @kulkarniankita. This error is very similar to the one mentioned in this (now closed) issue:

Do any of the comments in that issue help? If not, please let us know.