Skip to content

[ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object #793

Description

@dart200

Environment:

  • Operating System version: macOS 10.15.3
  • Firebase SDK version: firebase-admin 8.0.0 - 8.9.2
  • Firebase Product: Firestore
  • Node.js version: 12.16.0
  • NPM version: 6.13.4

Describe the problem

I noticed this issue when trying to upgrade my admin-sdk from 7.2.0 to something that does not use the legacy metadata endpoints.

Trying to use the admin sdk to access firestore in a jest test causes this error -- TypeError: The "path" argument must be of type string. Received an instance of ObjectTypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object

I do not notice this on my cloud functions deployment or any non jest scripts I've tried.

The stack trace is as follows:

TypeError: The "path" argument must be of type string. Received an instance of ObjectTypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object

  11 | describe('testing', () => {
  12 |   it ('does the thing', async () => {  
> 13 |     const doc = await adminDb.doc('movers/gea8cKBpFunx5VdE0lRw').get();
     |                 ^
  14 |     expect(doc.exists).toBe(true);
  15 |     console.log(doc.data());
  16 |   });

  at GrpcClient.loadProto (node_modules/google-gax/src/grpc.ts:166:23)
  at new FirestoreClient (node_modules/@google-cloud/firestore/build/src/v1/firestore_client.js:113:32)
  at ClientPool.clientFactory (node_modules/@google-cloud/firestore/build/src/index.js:329:26)
  at ClientPool.acquire (node_modules/@google-cloud/firestore/build/src/pool.js:87:35)
  at ClientPool.run (node_modules/@google-cloud/firestore/build/src/pool.js:164:29)
  at node_modules/@google-cloud/firestore/build/src/index.js:957:30
  at Firestore._retry (node_modules/@google-cloud/firestore/build/src/index.js:822:38)
  at Object.<anonymous> (test.js:13:17)

Relevant Code:

This template replicates the problem for me:

require('jest');
jest.setTimeout(20000);

const admin = require('firebase-admin');
admin.initializeApp({
  credential: admin.credential.cert(require("./<keyfile>.json")),
  databaseURL: "https://<project>.firebaseio.com",
});
const adminDb = admin.firestore();

describe('testing', () => {
  it ('does the thing', async () => {  
    const doc = await adminDb.doc('<collection>/<id>').get();
    expect(doc.exists).toBe(true);
    console.log(doc.data());
  });
});

My package dependencies are just:

"dependencies": {
  "firebase-admin": "^8.9.2",
  "jest": "^25.1.0"
}

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions