firebase / firebase/firebase-functions

Firestore Functions Triggers Breaks

Open
#1,922 8 comments 0 reactions 1 assignee Claimed by @ajperel View on GitHub
reproduced
Dominant language
TypeScript
Stars
1.1k
Forks
232
Avg merge
20h 46m
Merged PRs (30d)
15

Description

### Related issues

### [REQUIRED] Version info

**node:** 22

**firebase-functions:** "7.2.5", was also tested with 7.2.6-rc0

**firebase-tools:**

**firebase-admin:** 13.10.0

### [REQUIRED] Test case

```
exports.onDocWriteTest = onDocumentWritten({document: "collectionName/{docID}"}, async (event) => {

})

```

If the document end with empty space " ", for example the document name is "Test Document " with a space in the end, the trigger will results in a crash/error.
For any other document that does NOT end with an empty space, the trigger works as usual.

### [REQUIRED] Steps to reproduce

1. Create a trigger function for any type of document/collection
2. Create a document in the collection where the document ID has a space in the end of it, for example `Document ID `
3. The function will crash upon document write/create

### [REQUIRED] Expected behavior

The trigger should work as intended without crashing

### [REQUIRED] Actual behavior

The function trigger crashes with the following error:

```
Error: Resource name '//pubsub.googleapis.com/' is not valid.
at QualifiedResourcePath.fromSlashSeparatedString (/workspace/node_modules/@google-cloud/firestore/build/src/path.js:368:15)
at Firestore.snapshot_ (/workspace/node_modules/@google-cloud/firestore/build/src/index.js:846:97)
at Object.createBeforeSnapshotFromJson (/workspace/node_modules/firebase-functions/lib/common/providers/firestore.js:77:27)
at createBeforeSnapshot (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:180:45)
at makeChangedFirestoreEvent (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:214:69)
at func (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:313:26)
at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:119:25
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
```

It seems the path extraction breaks at fromSlashSeparatedString
### Were you able to successfully deploy your functions?

Yes

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.