Repository navigation
Description
Describe the Bug
I have a collection, let's call it myCollection, with an array-type field named myItems that has a specified defaultValue. Although the field is optional in my case, most of my collection items will have at least four elements in that array. It can be a bit tedious to click "Add item" multiple times, especially since the UI animation takes some time. As a result, I decided to always have four elements in the array field.
However, when trying to quickly add multiple collection items, I encounter the error: "The following field is invalid: id." Additionally, this issue interferes with the Postgres serial IDs, causing the "failed" IDs to be skipped.
Here is the code snippet:
export const MyCollection: CollectionConfig = {
slug: 'myCollection',
versions: {
drafts: true,
maxPerDoc: 100
},
admin: {
useAsTitle: 'name'
},
fields: [
{
type: 'tabs',
tabs: [
{
label: 'General',
fields: [
{
name: 'name',
type: 'text',
required: true
},
]
},
{
label: 'Content',
fields: [
// ...
{
name: 'myItems',
labels: {
singular: 'item',
plural: 'items'
},
type: 'array',
required: false,
defaultValue: Array(4).fill({ name: '', description: '' }),
fields: [
{
name: 'name',
type: 'text',
required: true
},
{
name: 'description',
type: 'text',
required: true
}
]
},
]
},
// ...
]
}
]
};I did some manual investigation and it indeed looks like it tries to submit the same IDs for the array elements.
I tried using defaultValue like this defaultValue: () => Array(4).fill({ name: '', description: '' }), but it didn't work either. It would be great if we could pass-in the callback to generate default value so it doesn't re-use the same object over and over.
Reproduction Steps
See the code snippet above for reference.
- Go to
myCollectionadmin page, clickCreate New. - Type in any
name, click Save Draft. - Go Back in browser without refreshing the page.
- You get the same "Create New" page, but with all empty fields.
- Type in any other
nameand click save draft - you would get the error.
Which area(s) are affected? (Select all that apply)
Not sure, area: core
Environment Info
Payload: 3.31.0
Node: 22.11.0
Activity
omaroubari commentedon May 15, 2025
were you able to resolve it?
simeiko commentedon May 17, 2025
As a workaround, I'm performing a full page refresh (F5), which works fine for now. However, a proper fix would still be appreciated.
androbro commentedon Jun 16, 2025
i also have this issue, ive dropped the database multiple times now to have it fixed. but after a while it just comes back.
MacPiston commentedon Aug 29, 2025
I'm encountering it frequently - the only solution is to just refresh the page
alexanderkalachev commentedon Sep 10, 2025
Same here
leosequani commentedon Dec 9, 2025
Same
georgeyasbic commentedon Dec 11, 2025
Im experiencing the same issue too.
anhdd-kuro commentedon Dec 19, 2025
Issues happen again, I Think this is critical , why no response from the team
jstarstech commentedon Dec 22, 2025
Same here
adrianoresende commentedon Jan 11, 2026
Same here, it is impossible to update the page.
adrianoresende commentedon Jan 11, 2026
I fixed it by deleting all versions on the affected block.
i.e., The error is with a block,
ForWhom, so I deleted all versions on_pages_v_blocks_for_whomand deleted some relation parent that doesn't exist anymore onpages_blocks_for_whom_{array}_listwhere array is a list inside of block.fix: resolve six request, validation and developer tooling reports
fix: address 24 Payload read, schema, version and tooling reports (#9)