Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Phantom item in collection

default discord avatar
arctomachine2 years ago
12

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
    Deleted User2 years 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.

  • default discord avatar
    jessrynkar2 years ago
    @456226577798135808

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



    @220641138267258892

    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



    @950202910095081473

    sounds possibly related to your issue fyi

  • default discord avatar
    arctomachine2 years ago

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

  • default discord avatar
    Deleted User2 years 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 🙂

  • default discord avatar
    jessrynkar2 years 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
    arctomachine2 years ago

    So how can I remove it without editing database?

  • default discord avatar
    jessrynkar2 years ago
    @220641138267258892

    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
    arctomachine2 years ago

    Only not found message

  • default discord avatar
    jessrynkar2 years ago

    And does it appear in the database?

  • default discord avatar
    arctomachine2 years ago

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

  • default discord avatar
    jessrynkar2 years ago
    @220641138267258892

    are you still experiencing this issue on payload@latest?

  • default discord avatar
    arctomachine2 years ago

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

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.