payload icon indicating copy to clipboard operation
payload copied to clipboard

DocumentDB unique error does not have keyValue in Error object, generic error shown

Open mvdve opened this issue 1 year ago • 2 comments

Link to reproduction

No response

Describe the Bug

The error message for unique field values is not working on Document DB. The keyValue variable is not present within the error object and so the generic error "something went wrong" is shown in production:

When connected to MongoDB:

ok: 0,
code: 11000,
codeName: 'DuplicateKey',
keyPattern: { slug: 1 },
keyValue: { slug: 'test' },
[Symbol(errorLabels)]: Set(0) {}

When connected to DocumentDB:

ok: 0,
operationTime: new Timestamp({ t: 1702377946, i: 1 }),
code: 11000,
[Symbol(errorLabels)]: Set(0) {}

Used here and here

To Reproduce

  • Run PayloadCMS 2.3.1 with DocumentDB
  • Create a unique field
  • Try to add two items with the same field value

Payload Version

2.3.1

Adapters and Plugins

db-mongodb

mvdve avatar Dec 12 '23 12:12 mvdve