Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error copying data from locale #11309

Open
cemcatik opened this issue Feb 20, 2025 · 1 comment
Open

Error copying data from locale #11309

cemcatik opened this issue Feb 20, 2025 · 1 comment
Assignees

Comments

@cemcatik
Copy link

Describe the Bug

When trying to copy a collection item with some block field from one locale to another an error is thrown in the console:

key not found: error:valueMustBeUnique
key not found: error:followingFieldsInvalid
[13:11:29] ERROR: There was an error copying data from "en" to "de"
    err: {
      "type": "ValidationError",
      "message": "error:followingFieldsInvalid id",
      "stack":
          ValidationError: error:followingFieldsInvalid id
              at upsertRow (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_graphql@_d4ced44587595027c0a831f66ae323dd/node_modules/@payloadcms/drizzle/dist/upsertRow/index.js:364:19)
              at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
              at async Object.updateOne (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_graphql@_d4ced44587595027c0a831f66ae323dd/node_modules/@payloadcms/drizzle/dist/update.js:66:20)
              at async updateDocument (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/dist/collections/operations/utilities/update.js:209:18)
              at async updateByIDOperation (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/payload/dist/collections/operations/updateByID.js:111:22)
              at async copyDataFromLocale (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_react-dom@19_eebf264c06a0120952f35ebbf5a4b948/node_modules/@payloadcms/ui/dist/utilities/copyDataFromLocale.js:214:8)
              at async copyDataFromLocaleHandler (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_react-dom@19_eebf264c06a0120952f35ebbf5a4b948/node_modules/@payloadcms/ui/dist/utilities/copyDataFromLocale.js:124:12)
              at async /Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:157:2088
              at async handleAction (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:156:21940)
              at async renderToHTMLOrFlightImpl (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:161:22397)
              at async doRender (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1574:34)
              at async responseGenerator (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1822:28)
              at async DevServer.renderToResponseWithComponentsImpl (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1832:28)
              at async DevServer.renderPageComponent (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:2259:24)
              at async DevServer.renderToResponseImpl (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:2297:32)
              at async DevServer.pipeImpl (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:959:25)
              at async NextNodeServer.handleCatchallRenderRequest (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/next-server.js:281:17)
              at async DevServer.handleRequestImpl (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:853:17)
              at async /Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/dev/next-dev-server.js:371:20
              at async Span.traceAsyncFn (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/trace/trace.js:153:20)
              at async DevServer.handleRequest (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/dev/next-dev-server.js:368:24)
              at async invokeRender (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/lib/router-server.js:230:21)
              at async handleRequest (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/lib/router-server.js:408:24)
              at async requestHandlerImpl (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/lib/router-server.js:432:13)
              at async Server.requestListener (/Users/cem.catikkas/workspace/gaia/postgres-localization-error/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/lib/start-server.js:146:13)
      "data": {
        "id": 2,
        "errors": [
          {
            "message": "error:valueMustBeUnique",
            "path": "id"
          }
        ]
      },
      "isOperational": true,
      "isPublic": false,
      "status": 400,
      "name": "ValidationError"
    }

Link to the code that reproduces this issue

https://github.com/cemcatik/payloadcms-localization-error

Reproduction Steps

I used pnpm create payload-app@latest command to create the project with website template.

How to reproduce

  1. Start postgres using docker compose up -d
  2. Start project pnpm dev
  3. Login to Admin panel
  4. Click on "Seed your database"
  5. Go to Pages collection, open Home
  6. Click "Copy to locale" and choose "de" under "Copy to"
  7. Click "Copy" button and observe the error in the console

Error in postgres logs:

payload_db-1  | 2025-02-20 21:11:29.449 UTC [79] ERROR:  duplicate key value violates unique constraint "pages_blocks_content_pkey"
payload_db-1  | 2025-02-20 21:11:29.449 UTC [79] DETAIL:  Key (id)=(67b79a771dcb1746ed1e2202) already exists.
payload_db-1  | 2025-02-20 21:11:29.449 UTC [79] STATEMENT:  insert into "pages_blocks_content" ("_order", "_parent_id", "_path", "_locale", "id", "block_name") values ($1, $2, $3, $4, $5, $6), ($7, $8, $9, $10, $11, $12) returning "_order", "_parent_id", "_path", "_locale", "id", "block_name"

select * from pages_blocks_content:

1,2,layout,en,67b79a771dcb1746ed1e2202,Content Block

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

area: core

Environment Info

Binaries:
  Node: 23.7.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.3.0
Relevant Packages:
  payload: 3.24.0
  next: 15.1.7
  @payloadcms/db-postgres: 3.24.0
  @payloadcms/email-nodemailer: 3.24.0
  @payloadcms/graphql: 3.24.0
  @payloadcms/live-preview: 3.24.0
  @payloadcms/live-preview-react: 3.24.0
  @payloadcms/next/utilities: 3.24.0
  @payloadcms/payload-cloud: 3.24.0
  @payloadcms/plugin-form-builder: 3.24.0
  @payloadcms/plugin-nested-docs: 3.24.0
  @payloadcms/plugin-redirects: 3.24.0
  @payloadcms/plugin-search: 3.24.0
  @payloadcms/plugin-seo: 3.24.0
  @payloadcms/richtext-lexical: 3.24.0
  @payloadcms/translations: 3.24.0
  @payloadcms/ui/shared: 3.24.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: 12
@cemcatik
Copy link
Author

Based on previously reported issue #10093

@JessChowdhury JessChowdhury self-assigned this Feb 21, 2025
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants