Describe the Bug
When creating a textField with hasMany: true in the Mongo DB version of payload, filtering with the contains operator is not possible and the admin view somewhat crashes.
Looking at the source code the issue seems to come from payload/packages/db-mongodb/src/queries/sanitizeQueryValue.ts line 451. Here the text field hasMany is not handled and if that field is an array of strings instead of a string formattedValue.replace() is not a function.
Link to the code that reproduces this issue
https://github.com/AlexRoosWork/text-field-has-many-contains-filter
Reproduction Steps
To reproduce the changes, add some values to the sample field of the users collection. Then in the users list view, add a filter for the sample field with the contains operator and add some value in the value. On enter the admin view crashes.
Which area(s) are affected?
db: mongodb
Environment Info
Binaries:
Node: 24.13.0
npm: 11.6.2
Yarn: 4.11.0
pnpm: 10.28.0
Relevant Packages:
payload: 3.76.1
next: 15.4.11
@payloadcms/db-mongodb: 3.76.1
@payloadcms/graphql: 3.76.1
@payloadcms/next/utilities: 3.76.1
@payloadcms/richtext-lexical: 3.76.1
@payloadcms/translations: 3.76.1
@payloadcms/ui/shared: 3.76.1
react: 19.2.1
react-dom: 19.2.1
Operating System:
Platform: linux
Arch: x64
Version: #1-NixOS SMP PREEMPT_DYNAMIC Fri Feb 6 15:55:51 UTC 2026
Available memory (MB): 64022
Available CPU cores: 20
Describe the Bug
When creating a textField with
hasMany: truein the Mongo DB version of payload, filtering with the contains operator is not possible and the admin view somewhat crashes.Looking at the source code the issue seems to come from
payload/packages/db-mongodb/src/queries/sanitizeQueryValue.tsline 451. Here the text fieldhasManyis not handled and if that field is an array of strings instead of a stringformattedValue.replace()is not a function.Link to the code that reproduces this issue
https://github.com/AlexRoosWork/text-field-has-many-contains-filter
Reproduction Steps
To reproduce the changes, add some values to the
samplefield of theuserscollection. Then in the users list view, add a filter for thesamplefield with thecontainsoperator and add some value in the value. On enter the admin view crashes.Which area(s) are affected?
db: mongodb
Environment Info