1
votes

I'm trying to use 2 wildcards :

functions.firestore
    .document('establishments/{establishmentId}/payment/payments/{paymentId}')

and getting the

"Error 3: The Request has errors".

However when using only 1 the function works normally:

functions.firestore
    .document('establishments/{establishmentId}')

Complete function code:

exports.myFunction = functions.firestore
    .document('establishments/{establishmentId}/payment/payments/{paymentId}')
    .onUpdate((change, context) => {
        return secondaryApp.firestore()
            .collection("myCollection").doc("myDocument")
            .update(change.after.data());
    })

--debug log:

[2021 - 07 - 13T16: 35: 32.864Z] << < HTTP RESPONSE BODY { "error": { "code":400, "message": "The request has errors", "status": "INVALID_ARGUMENT", "details": [{ "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [{ "field": "event_trigger", "description": "Expected value establishments/{establishmentId}/payment/payments/{paymentId} to match regular expression [^/]+/[^/]+(/[^/]+/[^/]+)*" }] }] } } ⚠ functions: failed to update function projects/myProject/locations / us - central1 / functions / myFunction

Firestore:

 - establishments: collection
   - {establishmentId}: document
     - payment: map
       - payments: array
         - {paymentId}: map
1

1 Answers

1
votes

Confirm that the path ends on a document and that it follows the pattern collection/document/collection/document/... I'd guess the path is supposed to be 'establishments/{establishmentId}/payments/{paymentId}'