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
25.7k stars 1.64k forks source link

[Unresolved] Upgrading to beta 108/109 causes duplicate entries when editing and drafts not working as expected #8441

Closed Collexi-Dev closed 1 month ago

Collexi-Dev commented 1 month ago

Link to reproduction

No response

Environment Info

Binaries:
  Node: 20.13.1
  npm: 10.5.2
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  payload: 3.0.0-beta.109
  next: 15.0.0-canary.160
  @payloadcms/db-mongodb: 3.0.0-beta.109
  @payloadcms/email-nodemailer: 3.0.0-beta.109
  @payloadcms/graphql: 3.0.0-beta.109
  @payloadcms/live-preview: 3.0.0-beta.109
  @payloadcms/live-preview-react: 3.0.0-beta.109
  @payloadcms/next/utilities: 3.0.0-beta.109
  @payloadcms/plugin-redirects: 3.0.0-beta.109
  @payloadcms/plugin-seo: 3.0.0-beta.109
  @payloadcms/richtext-lexical: 3.0.0-beta.109
  @payloadcms/translations: 3.0.0-beta.109
  @payloadcms/ui/shared: 3.0.0-beta.109
  react: 19.0.0-rc-5dcb0097-20240918
  react-dom: 19.0.0-rc-5dcb0097-20240918
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:41 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6031
  Available memory (MB): 36864
  Available CPU cores: 14

Describe the Bug

Not sure what the workflow is when a previous issue got closed but is unresolved, so creating this issue for visibility.

Original bug is described here: https://github.com/payloadcms/payload/issues/8430

I am using mongo in my Payload setup. I have a pretty basic Pages collection and had a few page entries. After updating from beta v107 to v108, when editing a pre-existing page a duplicate entry for the same ID is shown which both link to the same entry:

image Some observations:

Draft data is correctly saved, Publishing changes works and are shown as expected, Latest draft is not shown in preview but it instead shows a different fixed previous version, When creating a new entry in v108 no issues are observed.

The issue persists after updating to v109 as mentioned here: https://github.com/payloadcms/payload/issues/8430#issuecomment-2378452861

I had 1 old entry left created with v107, just updated from v108 to v109 and edited the page but it seems the issue still persists and I now have 3 duplicates:

image

Reproduction Steps

  1. Init project on beta.107
  2. Create and publish pages
  3. Update to beta.108
  4. Edit a previously published page => duplicate entry
  5. Update to beta.109
  6. Edit a (different) previously published page => triple entry

Adapters and Plugins

No response

Timothylp commented 1 month ago

I'm experiencing the same issue across all my projects; re-saving the duplicated entities, as mentioned in #8430, did not resolve the problem.

sourabpramanik commented 1 month ago

Facing the same issue It has to do something with the application layer. The duplicates are not in the DB, they happen when it queries the DB and populates the data.

stofolus commented 1 month ago

Until they fix the underlying issue. The way that I've fixed it was to find all versions where the parent field was of $type: string and replace them with the ObjectId version instead.

Then I went into the admin UI and published all the pages with a duplicate page and that seems to have cleared it all up for me

sourabpramanik commented 1 month ago

Until they fix the underlying issue. The way that I've fixed it was to find all versions where the parent field was of $type: string and replace them with the ObjectId version instead.

Then I went into the admin UI and published all the pages with a duplicate page and that seems to have cleared it all up for me

In my case the parent is null in db

github-actions[bot] commented 1 month ago

🚀 This is included in version v3.0.0-beta.110

Collexi-Dev commented 1 month ago

Confirmed all good now, thanks 👍

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.