firebase / extensions

Source code for official Firebase extensions
https://firebase.google.com/products/extensions
Apache License 2.0
893 stars 383 forks source link

🐛 [firestore-bigquery-export] fs-bq-import-collection can crash with wildcard notation #2202

Open dhlanm opened 4 weeks ago

dhlanm commented 4 weeks ago

[REQUIRED] Step 2: Describe your configuration

[REQUIRED] Step 3: Describe the problem

Say you have the setup described in the docs here, with collections users/user1/pets and users/user2/pets, but also admins/admin1/pets. If you set ${COLLECTION_GROUP_QUERY} to true and provide the collection path as ${users/{uid}/pets}

However, consider that collection admins/admin1/pets is many times larger than the user collections. Then, the code here may get a page of query results with only admin pets, which will be filtered out, resulting in an empty rows variable. This crashes the script with Error importing Collection to BigQuery: Error: You must provide at least 1 row to be inserted.

Steps to reproduce:

Create the situation above, and run the export script.

Expected result

The export should work as normal.

Actual result

The script crashes.