algolia / firestore-algolia-search

Apache License 2.0
112 stars 35 forks source link

Firestore Extension Installation No Longer Working #204

Open rsun11 opened 7 months ago

rsun11 commented 7 months ago

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

smomin commented 7 months ago

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

rsun11 commented 7 months ago

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 commented 7 months ago

@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 commented 7 months ago

entered:

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

smomin commented 6 months ago

hey @rsun11 is this still an issue?

rsun11 commented 6 months ago

Not sure. I've deployed the code manually through the cli so haven't used the extension in a while.

On Wed, May 8, 2024 at 2:36 PM Sajid Momin @.***> wrote:

hey @rsun11 https://github.com/rsun11 is this still an issue?

— Reply to this email directly, view it on GitHub https://github.com/algolia/firestore-algolia-search/issues/204#issuecomment-2101521480, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPFPW6CDHKUYVNT7ZKKW3LZBKLG5AVCNFSM6AAAAABFNQUI7CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBRGUZDCNBYGA . You are receiving this because you were mentioned.Message ID: @.***>

smomin commented 4 months ago

Update: Firebase team has mentioned that they will be support named database to be configured with the Firebase extension. Once they do officially support it, I will take a look at it.

jayman2989 commented 3 months ago

Just checking in to state that this IS still an issue. I have named databases configured in my algolia extensions (3 of them, dev, stage, and prod). We recently moved to named DBs in firestore, and Algolia is very unreliable about reading the documents from them. I consistently see logs of it attempting to read from the default DB instead of the named DB.

Error when performing Algolia index Error: 3 INVALID_ARGUMENT: The request was for database 'projects/project-id-here/databases/(default)' but was attempting to access database 'projects/project-id-here/databases/development'

mesrobk commented 19 hours ago

Just checking in to state that this IS still an issue. I have named databases configured in my algolia extensions (3 of them, dev, stage, and prod). We recently moved to named DBs in firestore, and Algolia is very unreliable about reading the documents from them. I consistently see logs of it attempting to read from the default DB instead of the named DB.

Error when performing Algolia index Error: 3 INVALID_ARGUMENT: The request was for database 'projects/project-id-here/databases/(default)' but was attempting to access database 'projects/project-id-here/databases/development'

I was also receiving this error. I realized setting the Force Data Sync to 'No' does mitigate the issue. Still a problem with the extension but a descent workaround.