Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore Extension Installation No Longer Working #204

Open
rsun11 opened this issue Mar 28, 2024 · 12 comments
Open

Firestore Extension Installation No Longer Working #204

rsun11 opened this issue Mar 28, 2024 · 12 comments

Comments

@rsun11
Copy link

rsun11 commented Mar 28, 2024

My guess is that an update was made last night in Firebase Cloud Functions to not allow Gen 1 triggers on a named firestore database.

So this line in extension.yaml doesn't seem to be supported anymore.

resources:
- name: executeIndexOperation
type: firebaseextensions.v1beta.function
description: >-
Firestore document-triggered function that creates, updates, or deletes data in Algolia.
properties: # LOCATION is a user-configured parameter value specified by the user
# during installation.
location: ${LOCATION}
runtime: nodejs18
eventTrigger:
eventType: providers/cloud.firestore/eventTypes/document.write
resource: #projects/${PROJECT_ID}/databases/${DATABASE_ID}/documents/${COLLECTION_PATH}/{documentID}

The fix looks to be a conversion to a gen 2 trigger: #169

@rsun11 rsun11 changed the title Firestore Extension No Longer Working Firestore Extension Installation No Longer Working Mar 28, 2024
@smomin
Copy link
Collaborator

smomin commented Mar 30, 2024

@rsun11 if you have the time to create a PR, I can review it. I am going to do some investigation on this.

@rsun11
Copy link
Author

rsun11 commented Mar 30, 2024

Tried deploying the same code to a gen 2 trigger but the database context is referencing the default database so “exists” property always returned false and calls to the named database throws an exception.

@smomin
Copy link
Collaborator

smomin commented Apr 2, 2024

@rsun11 can you share your configuration? the Firebase team has not heard of this issue so they are wondering if the extension was misconfigured.

@rsun11
Copy link
Author

rsun11 commented Apr 2, 2024

entered:

  • extension instance ID: nucleus-70fd6e56-973f-4436-b650-dc308ddc9b2a
  • Database ID: nucleus-70fd6e56-973f-4436-b650-dc308ddc9b2a
  • collection path: products
  • Force Data Sync: no
  • algolia index name
  • algolia application id
  • full index existing documents: false
  • cloud functions location: us-west3

Tried again this morning and the same issue is happening...

Finally got the trigger to work with:

export const executeIndexOperation = onDocumentWritten( { document: 'documents/{documentId}', database: DATABASEID, region: REGION, }, async (change): Promise<void> => {

but this only works when deployed using the firebase cli.

@rsun11
Copy link
Author

rsun11 commented Apr 2, 2024

Also, executeFullIndexOperation wasn't working with a named database. The query would always return results from the default database. Had to update to:

    "firebase-admin": "^12.0.0",
    "firebase-functions": "^4.8.2",

for it to start working again.

@smomin
Copy link
Collaborator

smomin commented Apr 8, 2024

hey @rsun11 I am going through the updates you mentioned here. I am also talking to the Firebase team which seems surprised that I had this working in gen1 before some update that broke it. will let you know what happens.

@rsun11
Copy link
Author

rsun11 commented Apr 8, 2024

One thing to try would be to deploy the current code as a gen 2 trigger but with the firebase package updates from above.

@smomin
Copy link
Collaborator

smomin commented Apr 11, 2024

hey @rsun11

I tried implementing you suggestions. using the CLI deploy the update code, fails with this error message:

- update firestore-algolia-search-s4eg
; RESOURCE_ERROR at /deployments/firebase-ext-firestore-algolia-search-s4eg/resources/executeIndexOperation: {"ResourceType":"gcp-types/cloudfunctions-v1:projects.locations.functions","ResourceErrorCode":"400","ResourceErrorMessage":"Cannot create Firestore trigger for projects/algolia-store/databases/test. Triggers must be created with a \"(default)\" Firestore Native database. See https://firebase.google.com/docs/firestore/extend-with-functions#limitations."}

What steps did you take to implement gen2 versions for the extension.

@rsun11
Copy link
Author

rsun11 commented Apr 11, 2024

If you change the function to

export const executeIndexOperation = onDocumentWritten( { document: 'documents/{documentId}', database: DATABASEID, region: REGION, }, async (change): Promise<void> => {

the deployment will detect the signature as gen 2. I don’t think DatabaseId, document path, and region could not be stored as environment variables since the deployment needs those values populated during deployment to create the trigger.

@smomin
Copy link
Collaborator

smomin commented Apr 19, 2024

hey @rsun11 I am working with the firebase team to see if we can get this resolved. No eta at the moment.

@smomin
Copy link
Collaborator

smomin commented May 8, 2024

hey @rsun11 is this still an issue?

@rsun11
Copy link
Author

rsun11 commented May 8, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants