payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
24.68k stars 1.56k forks source link

Collection throws ValidationError when using slug `pages` #7250

Closed makunoia closed 3 months ago

makunoia commented 3 months ago

Link to reproduction

No response

Payload Version

3.0.0-beta.67

Node Version

v20.14.0

Next.js Version

15.0.0-rc.0

Describe the Bug

The Pages collection that comes with the fresh install of Payload v3 throws a ValidationError when adding a second item in the CMS. It seems to be trying to validate the action, but I find it weird since I'm already logged in to the CMS.

My other collections work just fine. I've even tried everything from commenting out all imports and all fields, even duplicating the collection with the same fields, and worked, tried to deploy the collection to production, and it also worked just fine there.

I eventually discovered this only happens if I set the collection slug to pages. Other slug values such as webpage, sitepage make adding items to the collection work.

The error only happens to slug pages Is this intended, or am I missing something here?

Reproduction Steps

Consider the following Page collection:

import { CollectionConfig } from "payload";
const Pages: CollectionConfig = {
  slug: "pages",
  labels: {
    singular: "Page",
    plural: "Pages",
  },
  admin: {
    useAsTitle: "name",
    defaultColumns: ["name", "id"],
  },
  fields: [
    {
      label: "Page Title",
      name: "name",
      type: "text",
    },
  ],
};
export default Pages;
  1. Add first Page, everything runs as expected

    image
  2. Add second record, throws a Validation error

    image

Adapters and Plugins

No response

paulpopus commented 3 months ago

@makunoia That validation error mentioning "email" tells me that this collection was at one point auth enabled and you have ghost content in your database.

Using something like Beekeeper Studio or Mongo Compass can you connect to your database and inspect it for either content items that arent listed in Payload or for fields on existing items that shouldn't be there?

I bet this will fix your issue but let me know if it doesnt.

github-actions[bot] commented 1 month ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.