verida / data-connector-server

1 stars 2 forks source link

Deleting a record with the endpoint crash the server #181

Open aurelticot opened 2 weeks ago

aurelticot commented 2 weeks ago

I wish iI had more details but I have only tested from the Vault UI.

When calling the delete record endpoint DELETE /api/rest/v1/ds/:base64SchemaUrl/:recordId?destroy=false the server crashes completely.

Weird thing is the DsController.delete surrounds its logic with a try/catch and returns a 500 in case or error, but when called, it is actually a success, with a 200 and indeed, the record doesn't exist.

So something happens elsewhere in the app ... or it's in the delete endpoint code but deeper in the SDK?

I made sure to not make any other call after the delete.

Also, it's not all the time reproducible, 50% of the time, it works without error.

I get the following error in the logs (I put debug locally to identify what happens)

[2024-11-11T15:26:17.453] [DEBUG] default - Inside ds#delete endpoint
[2024-11-11T15:26:17.820] [DEBUG] default - schemaName for the deletion https://common.schemas.verida.io/social/event/v0.1.0/schema.json
[2024-11-11T15:26:17.820] [DEBUG] default - opening the datastore
[2024-11-11T15:26:17.821] [DEBUG] default - datastore opened
[2024-11-11T15:26:17.821] [DEBUG] default - recordId to delete google-115............560-03u..........kgck // recordId redacted
[2024-11-11T15:26:17.821] [DEBUG] default - destroy parameter false
[2024-11-11T15:26:17.822] [DEBUG] default - deleting the record
[2024-11-11T15:26:17.841] [DEBUG] default - record deleted
[2024-11-11T15:26:17.841] [DEBUG] default - returning the successful response

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^
Error
    at new CustomPouchError (/Users/aurel/dev/verida/data-connector-server/node_modules/pouchdb/lib/index.js:656:21)
    at createError (/Users/aurel/dev/verida/data-connector-server/node_modules/pouchdb/lib/index.js:665:10)
    at /Users/aurel/dev/verida/data-connector-server/node_modules/pouchdb/lib/index.js:5191:27
    at /Users/aurel/dev/verida/data-connector-server/node_modules/pouchdb/lib/index.js:4222:9
    at /Users/aurel/dev/verida/data-connector-server/node_modules/pouchdb/lib/index.js:4053:13 {
  status: 404,
  name: 'not_found',
  message: 'missing',
  error: true,
  reason: 'deleted',
  docId: 'google-115............560-03u..........kgck' // recordId redacted
}