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.

BSONTypeError

default discord avatar
atrevid0002 years ago
2

Hi there, I'm new to Payload CMS. When searching collections I am getting errors in the UI with BSONTypeError in logs due to Payload querying mongodb id field as a string. This breaks all search functionality for me in any box where I need to lookup by listSearchableFields.



[22:52:26] ERROR (payload): BSONTypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer






Okay super confusing, but it looks like if you add "useAsTitle" then it defaults to using the text field and not the ID.

  • discord user avatar
    denolfe
    2 years ago

    Glad you figured it out. I had not seen that error before. Just to clarify, this was just because of an invalid value for

    useAsTitle

    ?

  • default discord avatar
    atrevid0002 years ago
    @967118574445547650

    No, if you don't include useAsTitle the collection uses a mongo object id as it's title/search field, which is like a 24 character string. If you try to type anything in the search boxes it breaks in the UI and returns a BSONType error.

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.