`indexToTypesenseOnFirestoreWrite.js` does not delete documents when the docId has a hash `#`
costcocompanion opened this issue · 2 comments
Description
We use the typesense/firestore-typesense-search@0.4.2
firebase extension to sync (create, update, delete) documents to our typesense cluster. We have a collection that has document IDs that contain hashes #
, e.g. "AAAtest#000"
While document.creates are sync'd with the extension - document.deletes are failing
Steps to reproduce
- Create a firebase collection
- Add the
firestore-typesense-search
firebase extension using version0.4.2
- Create a document with a docID with a hash symbol, e.g. "AAAtest#000"
- Wait for the extension to sync the document to typesense
- Delete the document in firebase (which should trigger the extension to delete the document in typesense)
- Observe that that the delete sync to typesense fails and document still exists and is searchable in typesense
Expected Behavior
Expected behavior is that upon deleting the document in firebase the document is also deleted in typesense
Actual Behavior
I go to firebase console, find a document with a hash sign (e.g. AAAtest#000
), and issue a delete command.
The following message in google cloud logs:
Deleting document AAAtest#000
Error:
Error: Request failed with HTTP code 404 | Server said: Could not find a document with id: AAAtest
at .ApiCall.customErrorForResponse ( /workspace/node_modules/typesense/lib/Typesense/ApiCall.js:226 )
at .ApiCall.performRequest ( /workspace/node_modules/typesense/lib/Typesense/ApiCall.js:118 )
at .processTicksAndRejections ( [internal/process/task_queues.js:95](https://console.cloud.google.com/debug?referrer=fromlog&file=internal%2Fprocess%2Ftask_queues.js&line=95&appModule=ext-firestore-typesense-search-warehouses-indexToTypesenseOnFir&appVersion=&project=costco-companion-app-6d932&supportedpurview=project) )
Please notice that in the error message the characters after the hash symbol is dropped:
- DocID:
AAAtest#000
- DocID referenced in error logs:
AAAtest
As expected (since the delete fails) the document still exists in our typesense database
Metadata
Typesense Version:
Typesense v0.23.1
typesense/firestore-typesense-search@0.4.2
OS:
functions are executed as a Firebase Cloud function
node v14
typescript
@costcocompanion Good catch. I've pushed out an update in this RC release of the extension: https://console.firebase.google.com/project/_/extensions/install?ref=typesense/firestore-typesense-search@1.0.0-rc.4
Could you give it a shot and let me know how it works?
@jasonbosco works great, thanks for the quick fix!