Repository navigation
Description
Link to reproduction
https://github.com/cafaroo/Makebelieve-landing-page/pull/49 (private repo — repro snippets inlined below)
Describe the Bug
`payload.update({ collection, id, locale: 'sv', data: { blocks: [...] } })` throws `ValidationError: "The following field is invalid: id"` with `data.errors: [{ message: "Value must be unique", path: "id" }]` when the `blocks` field is non-localized but contains localized inner fields, and the blocks array passed back contains the `id` keys returned from a prior `find`.
This is the same root cause as #11309 ("Copy To Locale" error) which was partially fixed in PR #11402 by stripping the top-level `id` from update payloads. The fix did not address nested block-array IDs, which still trigger the same primary key constraint violation on `pages_blocks_*_pkey`.
Reproduction Steps
- Define a collection with a non-localized `blocks` field where inner fields are `localized: true`. Versioning enabled.
```ts
// collections/Pages.ts
{
slug: 'pages',
versions: { drafts: { autosave: { interval: 2000 } }, maxPerDoc: 25 },
fields: [
{ name: 'title', type: 'text', localized: true },
{
name: 'blocks',
type: 'blocks',
blocks: [
{
slug: 'hero',
fields: [
{ name: 'badge', type: 'text', localized: true },
{ name: 'titleLine1', type: 'text', required: true, localized: true },
{ name: 'image', type: 'upload', relationTo: 'media', required: true },
],
},
],
},
],
}
```
- Populate the doc with EN-locale data (works).
- Try to add SV-locale text on the same blocks:
```ts
const en = await payload.find({ collection: 'pages', where: { slug: { equals: 'home' } }, locale: 'en', limit: 1, depth: 0 });
const blocks = en.docs[0].blocks; // each has the id Payload assigned
const svBlocks = blocks.map(b => ({ ...b, badge: 'SV badge', titleLine1: 'SV title' }));
await payload.update({
collection: 'pages',
id: en.docs[0].id,
locale: 'sv',
data: { blocks: svBlocks },
});
```
Result
```json
{
"name": "ValidationError",
"message": "The following field is invalid: id",
"data": {
"errors": [{ "message": "Value must be unique", "path": "id" }],
"collection": "pages"
}
}
```
Stack points to `Object.updateOne` inside Payload runtime.
Expected behavior
`payload.update` with a non-default `locale` and the same block IDs as the existing rows should write the localized fields to the corresponding `*_locales` rows and leave non-localized columns intact, mirroring the "Copy To Locale" UI pattern.
Workarounds we tried
-
`stripIdsDeep` (recursive id removal) — bypassed the validation error but Payload then DELETE+INSERTs all block rows, nulling the EN-locale fields since they aren't in the update payload. Verified via direct DB query: `{ heroBadge: null, heroTitleLine1: null, faqTitle: null }` for EN after running. Lost prod data; restored by re-running EN populate.
-
`locale: 'all'` with per-field `{ en, sv }` objects — works correctly. Both locales preserved in a single update. This is what we shipped.
The first workaround is what users are most likely to try (it matches the partial fix in #11402) but it's actively destructive.
Versions
- payload `3.84.1`
- @payloadcms/db-postgres `3.84.1`
- Postgres (Neon)
- Node 22
Adapter version
@payloadcms/[email protected]
Activity
cafaroo commentedon Apr 28, 2026
Closing — opened in error without the repo owner's authorization. Apologies for the noise.
github-actions commentedon May 6, 2026
This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.