Firestore: Document parent name lacks "/"

Viewed 1025

I am using jest to perform integration tests to firestore. I expected to receive document consisting of fields equal to field1 and field2. However, I have received the below error instead.

I have tried creating a composite index in firecase console but the problem still persists. This situation seems to only happen during testing as the code works fine when I run the Node.js app normally. I have narrowed the error to come from the code below:

const response = await fs.collection('collection1').where('field1', '==', field1).where('field2', '==', field2).get();

The error message is as such:

Error: FirebaseError: [code=invalid-argument]: Document parent name "projects/int-test-1-5tb01cf1-poiu-0qa8-lk87-e1aeff685f2d/databases/(default)" lacks "/" at index 76.
2 Answers

You’re firebase tools have just updated from 6.9 to 7.0.

This is a breaking change in version 7.

We fixed it by setting the max version to 6.9. I’ll find the line to set the version... one sec.

So we use a script for our tests and the line in the script is...

sudo npm install --unsafe-perm -g firebase-tools@6.9.2

You should be able to set 6.9.2 as your max version of firebase tools to fix this.

Upgrading the package @firebase/testing to version 0.11.8 (matching up with firebase-admin 8.3.0) and running the 7.2.0 version of the emulator fixed this issue for me.

Related