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

Block fields causes error when copying data from one locale to another #10093

Open
ivankyrpa opened this issue Dec 20, 2024 · 0 comments
Open
Labels
status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@ivankyrpa
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:

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][email protected]__k5ywpqrp57ji25edtdhcui6mje/node_modules/@payloadcms/drizzle/dist/upsertRow/index.js:347:19)
              at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
              at async Object.updateOne (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected]__k5ywpqrp57ji25edtdhcui6mje/node_modules/@payloadcms/drizzle/dist/update.js:64:20)
              at async updateByIDOperation (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/payload/dist/collections/operations/updateByID.js:279:22)
              at async copyDataFromLocale (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_re_iitep6qeqia34bg4guvfwem574/node_modules/@payloadcms/ui/dist/utilities/copyDataFromLocale.js:199:8)
              at async copyDataFromLocaleHandler (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_re_iitep6qeqia34bg4guvfwem574/node_modules/@payloadcms/ui/dist/utilities/copyDataFromLocale.js:109:12)
              at async /Users/ivankyrpa/Projects/payload-cms-3-9-0/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/ivankyrpa/Projects/payload-cms-3-9-0/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/ivankyrpa/Projects/payload-cms-3-9-0/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:22192)
              at async doRender (/Users/ivankyrpa/Projects/payload-cms-3-9-0/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1565:34)
              at async responseGenerator (/Users/ivankyrpa/Projects/payload-cms-3-9-0/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1813:28)
              at async DevServer.renderToResponseWithComponentsImpl (/Users/ivankyrpa/Projects/payload-cms-3-9-0/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1823:28)
              at async DevServer.renderPageComponent (/Users/ivankyrpa/Projects/payload-cms-3-9-0/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:2250:24)
              at async DevServer.renderToResponseImpl (/Users/ivankyrpa/Projects/payload-cms-3-9-0/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:2288:32)
              at async DevServer.pipeImpl (/Users/ivankyrpa/Projects/payload-cms-3-9-0/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/ivankyrpa/Projects/payload-cms-3-9-0/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/ivankyrpa/Projects/payload-cms-3-9-0/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/ivankyrpa/Projects/payload-cms-3-9-0/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/ivankyrpa/Projects/payload-cms-3-9-0/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/ivankyrpa/Projects/payload-cms-3-9-0/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/ivankyrpa/Projects/payload-cms-3-9-0/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/ivankyrpa/Projects/payload-cms-3-9-0/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/ivankyrpa/Projects/payload-cms-3-9-0/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/ivankyrpa/Projects/payload-cms-3-9-0/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": 3,
        "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/ivankyrpa/payload-cms-3.0.9

Reproduction Steps

I used npx create-payload-appcommand to create repro repo. Please use link to reproduction for the full example.

How to reproduce

  1. Create a BlockTest item with block field in "en" locale
  2. Click "Copy to locale" link and choose "de" locale as a target
  3. Click "Copy" button and observe the error in the console

BlockTests collection:

export const BlockTests: CollectionConfig = {
  slug: 'blockTests',
  fields: [
    {
      name: 'text',
      type: 'text',
      localized: true,
    },
    {
      name: 'content',
      type: 'blocks',
      localized: true,
      blocks: [
        {
          slug: 'text',
          fields: [
            {
              name: 'text',
              type: 'text',
            },
          ],
        },
      ],
    },
  ],
}

Payload config:

export default buildConfig({
  collections: [BlockTests, ...],
  localization: {
    defaultLocale: 'en',
    locales: ['en', 'de'],
    fallback: true,
  },
  ...
})

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

area: core

Environment Info

Binaries:
  Node: 20.12.2
  npm: 10.5.0
  Yarn: 1.22.22
  pnpm: 9.10.0
Relevant Packages:
  payload: 3.9.0
  next: 15.1.0
  @payloadcms/db-postgres: 3.9.0
  @payloadcms/email-nodemailer: 3.9.0
  @payloadcms/graphql: 3.9.0
  @payloadcms/next/utilities: 3.9.0
  @payloadcms/payload-cloud: 3.9.0
  @payloadcms/richtext-lexical: 3.9.0
  @payloadcms/translations: 3.9.0
  @payloadcms/ui/shared: 3.9.0
  react: 19.0.0
  react-dom: 19.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

1 participant