payloadcms / payloadcms/payload

"Value must be unique" error when maxDocs is reached

Open
#11,550 20 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

stale status: cant-reproduce
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

I'm not sure what the default behaviour is when the versions of a collection reach the maxDocs (20 in my case), but I'm getting the following errors:

"data": {
        "id": 29,
        "errors": [
          {
            "message": "Value must be unique",
            "path": "id"
          }
        ]
      },
      "isOperational": true,
      "isPublic": false,
      "status": 400,
      "name": "ValidationError"
    }

Link to the code that reproduces this issue

working on it

Reproduction Steps

working on it

Which area(s) are affected? (Select all that apply)

Not sure

Environment Info
Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: 1.22.22
  pnpm: 9.13.2
Relevant Packages:
  payload: 3.25.0
  next: 15.2.0
  @payloadcms/db-postgres: 3.25.0
  @payloadcms/email-nodemailer: 3.25.0
  @payloadcms/graphql: 3.25.0
  @payloadcms/live-preview: 3.25.0
  @payloadcms/live-preview-react: 3.25.0
  @payloadcms/next/utilities: 3.25.0
  @payloadcms/plugin-cloud-storage: 3.25.0
  @payloadcms/plugin-nested-docs: 3.25.0
  @payloadcms/plugin-seo: 3.25.0
  @payloadcms/richtext-lexical: 3.25.0
  @payloadcms/storage-s3: 3.25.0
  @payloadcms/translations: 3.25.0
  @payloadcms/ui/shared: 3.25.0
  react: 19.0.0
  react-dom: 19.0.0
Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:22:00 PST 2025; root:xnu-11215.81.4~3/RELEASE_X86_64
  Available memory (MB): 16384
  Available CPU cores: 8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file, test, or reproduction is provided. Start by reproducing collection version behavior with maxDocs set to 20 in the listed Payload and Postgres environment, then trace the version-limit and unique-ID validation paths; done means the expected maxDocs behavior is established and the error is fixed or explained with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, postgresql, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.