BSONTypeError

default discord avatar
chrisg
last month
6

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
    Payload Team
    last month

    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
    chrisg
    last month

    @denolfe 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.

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.