Skip to content

Firestore Functions Triggers Breaks #1922

Description

@displayDev-spec

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions