on create new post or duplicate it throws error ("The following field is invalid: filename")
const Posts: CollectionConfig = {
slug: 'posts',
admin: {
defaultColumns: ['title', 'author', 'category', 'tags', 'status'],
useAsTitle: 'title',
},
access: {
create: () => true,
read: () => true, //isAdminOrSelf,
delete: isAdminOrSelf,
update: isAdminOrSelf
},
fields: [
...
{
type: 'tabs',
tabs: [
{
label: 'Hero',
description: 'This will appear within the tab above the fields.',
fields: [
{
name: 'title',
type: 'text',
required: true,
},
{
name: 'slug',
label: 'Slug',
type: 'text',
// required: true,
unique: true,
admin: {
position: 'sidebar',
},
hooks: {
beforeValidate: [
formatSlug('title'),
],
},
},
{
name: 'postImage',
type: 'upload',
relationTo: 'media',
required: true,
}
]
},
]
},
],
}
Hey there! I'm having the same problem
Hey all check this out
https://github.com/payloadcms/payload/issues/1877@Jarrod I just upgrade payload 1.5.9 but same problem, when posts is empty and create new, it works fine, but after, even duplicate any post or adding new one, then throw me this error. 🤷🏼
@Jarrod same error on create or duplicate post, i don't have a field named "filename",
{
"errors": [
{
"name": "ValidationError",
"message": "The following field is invalid: filename",
"data": [
{
"message": "Value must be unique",
"field": "filename"
}
]
}
]
}
I found something in codebase and I tried to drop all collection from MongoDB and now it works fine 🥳
// Handle uniqueness error from MongoDB
throw error.code === 11000 && error.keyValue
? new ValidationError([{ message: 'Value must be unique', field: Object.keys(error.keyValue)[0] }], t)
: error;
@Jarrod Unfortunately I'm still encountering this issue with Payload v1.6.28 :/ Uploading works fine, but when I try to add a relationship on an "Upload" type field, I get the same error message
@Jarrod I also have this issue on 1.6.32
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.