payload icon indicating copy to clipboard operation
payload copied to clipboard

Cannot delete any collection object with Azure CosmosDB: Transaction is not active

Open shazz opened this issue 8 months ago • 2 comments

Link to reproduction

No response

Describe the Bug

I configured payloadcms to connect to my Azure Cosmos DB for MongoDB account. It works well except when I try to delete any kind of Collection object. It fails and I can see in pino logs:

{"level":50,"time":1718663749924,"pid":226951,"hostname":"****","name":"payload","msg":
"MongoServerError: Error=2, Details='Response status code does not indicate success: BadRequest (400); 
Substatus: 1101; ActivityId: 3c364136-6d79-4dc0-89d8-e4d67641ca62; 
Reason: (Response status code does not indicate success: 
BadRequest (400); Substatus: 1101; 
ActivityId: 3c364136-6d79-4dc0-89d8-e4d67641ca62; Reason: (Response status code does not indicate success: 
BadRequest (400); 
Substatus: 1101; 
ActivityId: 3c364136-6d79-4dc0-89d8-e4d67641ca62; 
Reason: (Message: {\"Errors\":[\"Transaction is not active\"]}
ActivityId: 3c364136-6d79-4dc0-89d8-e4d67641ca62, 
Request URI: /apps/3e76277b-491a-43ea-877f-4c9e1cbbbd9f/services/f77f5fb7-8df6-4fdd-996c-5eb222ad13a4/partitions/6ed5b480-e957-466a-a862-659e89c243e3/replicas/133631013038295515p/, 
RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.20348 cosmos-netstandard-sdk/3.18.0);););
    at /***/node_modules/mongodb/src/operations/delete.ts:135:44
    at /***/node_modules/mongodb/src/cmap/connection_pool.ts:569:13
    at /***/node_modules/mongodb/src/sdam/server.ts:367:13
    at handleOperationResult (/***/node_modules/mongodb/src/sdam/server.ts:500:14)
    at Connection.onMessage (/***/node_modules/mongodb/src/cmap/connection.ts:461:5)
    at MessageStream.<anonymous> (***/node_modules/mongodb/src/cmap/connection.ts:241:56)
    at MessageStream.emit (node:events:519:28)
    at MessageStream.emit (node:domain:488:12)
    at processIncomingData (/***/node_modules/mongodb/src/cmap/message_stream.ts:188:12)
    at MessageStream._write (/***/node_modules/mongodb/src/cmap/message_stream.ts:69:5)"}

To Reproduce

  1. Create any collection with delete enabled:
import type { CollectionConfig } from 'payload/types'

const Categories: CollectionConfig = {
    access: {
        delete: () => true,
        update: () => true,
        read: () => true,
    },
    admin: {
        useAsTitle: 'title',
    },
    fields: [
        {
            name: 'title',
            type: 'text',
            required: true,
        },
    ],
    slug: 'categories',
}

export default Categories
  1. With the admin webpage, create a category
  2. With the admin webpage, delete a category
  3. Nothing happens visually
  4. check the logs

Payload Version

create-payload-app@latest / @payloadcms/db-mongodb@^1.0.0

Adapters and Plugins

db-mongodb

Any idea how to fix this issue?

shazz avatar Jun 17 '24 22:06 shazz