Phantom item in collection

default discord avatar
Arctomachine
2 months ago
13

I have phantom item in one of collections. It appears to be independent item, while being duplicate of another existing item. But clicking on it returns only error "not found".


How did it happen? How can I fix it?



To fix - I mean without manually deleting it from database

  • default discord avatar
    Martin R
    2 months ago

    Do you mean to fix the course of why ghost duplication happens?


    There is a bug when editing collections through the relationship popups; if you save the collection more than once, it creates a duplicate.

  • discord user avatar
    jesschow
    Payload Team
    2 months ago

    @Martin R that is interesting I am going to try and replicate this.



    @Arctomachine do your remember how the original item (the one that has a phantom copy now) was created? i.e. through

    createNew

    on your collection, or through a relationship or post req



    @johnmadrigal_ sounds possibly related to your issue fyi

  • default discord avatar
    Arctomachine
    2 months ago

    No, not sure about how it was created. Been few months since then. Probably from its collection.

  • default discord avatar
    Martin R
    2 months ago

    1. Login to

    https://demo.payloadcms.com/admin

    2. Navigate to posts


    3. Create a new category by clicking on the +


    4. Fill out the Name


    5. Click Save


    6 .Click Save


    7. Click Save


    8. Click Save


    9. Navigate to Categories 


    10. Fix the bug 🙂

  • discord user avatar
    jesschow
    Payload Team
    2 months ago

    That behavior is not necessarily a bug, you should be allowed to create multiple documents from the drawer if you need - but you can definitely opt to prevent this behavior, in the demo for example you could add

    unique: true

    the category name field which would stop you on the second save.

  • default discord avatar
    Arctomachine
    2 months ago

    So how can I remove it without editing database?

  • discord user avatar
    jesschow
    Payload Team
    2 months ago

    @Arctomachine sorry the response above was to the scenario Martin described. Your issue is slightly different and I have still not been able to replicate. If you go to the endpoint for that doc in your browser (…/api/[collection]/[id]) - what does that show?

  • default discord avatar
    Arctomachine
    2 months ago

    Only not found message

    image.png
  • discord user avatar
    jesschow
    Payload Team
    2 months ago

    And does it appear in the database?

  • default discord avatar
    Arctomachine
    2 months ago

    In main collection - no. In _versions - there is one item that refers to its id as parent

    image.png
  • discord user avatar
    jesschow
    Payload Team
    last month

    @Arctomachine are you still experiencing this issue on payload@latest?

  • default discord avatar
    Arctomachine
    last month

    No. I ran migration script that I found in one of patchnotes, it seems to have fixed it

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.