Cannot reach your data. Search function no longer works

Hi team,
I encounter difficulties on two customer and drivers collections. The search function no longer works and I have this error. See capture and configuration.

# Cannot reach your data
Your server may be down or your database connection broken.
Please check your server logs for more information.

“forest-express-mongoose”: “^9.5.6”,

“meta”: {
“database_type”: “MongoDB”,
“liana”: “forest-express-mongoose”,
“liana_version”: “6.7.2”,
“engine”: “nodejs”,
“engine_version”: “10.22.1”,
“orm_version”: “5.11.13”
}
}

mongoDB 6.0

I want to specify that the search works on other collections. I think there is an evolution to be applied in the NODE code.JS 14.18. Can you help me please

Hello @Stephane_Evrard, welcome to the community :wave:
In order for us to better help you, could you please provide the following info:

  • Project name: …
  • Team name: …
  • Environment name: …
  • Type of project (cloud or self-hosted): …
  • Agent technology: (nodejs, php, rails, python)
  • Agent (forest package) name & version: …
  • Database type: …
  • Recent changes made on your end if any: …

Thanks :pray:

Hi Nicolas,
project name roby
admin
prod
cloud
node
“forest-express-mongoose”: “^9.5.6”,

“meta”: {
“database_type”: “MongoDB”,
“liana”: “forest-express-mongoose”,
“liana_version”: “6.7.2”,
“engine”: “nodejs”,
“engine_version”: “10.22.1”,
“orm_version”: “5.11.13”
}
}

mongoDB 6.0

no recente release no update less 6 months.

ok thanks for the details. I have found your project :pray:

Since this is a self-hosted project, can you provide the errors logs that are displayed on your agent server while trying to search the problematic collections ? You should be using a dev environment, as you it will have more log details

Thanks

HI Niclolas,
Our logs give nothing, the problem is on your side. We have the same problem in all environements. We do not see when we launch the search with a name or a mobile or other we have directly this message. Have you carried out a migration recently?
TKS
My email stephane@sas-aton.fr

Do you have a Channel Slack for clarify the situation ?
I can test with you in live on UAT ENV.

When i check the collection of Drivers, work well.

server-v5.0_1  | 2025-03-04T12:51:42.328Z - info: GET /v5.0/forest-admin/api/forest/drivers?timezone=Europe%2FParis&fields%5Bdrivers%5D=createdCountryFlag%2Cfullname%2CcreatedCity%2CdriverVehicleTypeEnum%2CdriverStatus%2CdriverTaxiNumber%2Cemail%2CdriverVehicleTypeIcon%2CphoneNumber%2CcreatedAt%2ClastLoginAt%2CisDriverAvailable%2CdriverProfileCompleted%2CsessionMode%2CisDriverLead%2CdriverShortId%2CturnOver&fields%5BturnOver%5D=_id&page%5Bnumber%5D=1&page%5Bsize%5D=30&sort=id 304 142ms
nginx_1        | 172.17.0.2 - - [04/Mar/2025:12:51:42 +0000] "GET /v5.0/forest-admin/api/forest/drivers?timezone=Europe%2FParis&fields%5Bdrivers%5D=createdCountryFlag%2Cfullname%2CcreatedCity%2CdriverVehicleTypeEnum%2CdriverStatus%2CdriverTaxiNumber%2Cemail%2CdriverVehicleTypeIcon%2CphoneNumber%2CcreatedAt%2ClastLoginAt%2CisDriverAvailable%2CdriverProfileCompleted%2CsessionMode%2CisDriverLead%2CdriverShortId%2CturnOver&fields%5BturnOver%5D=_id&page%5Bnumber%5D=1&page%5Bsize%5D=30&sort=id HTTP/1.1" 304 0 "https://app.forestadmin.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36"
mongo_1        | {"t":{"$date":"2025-03-04T12:51:44.004+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn2","msg":"Slow query","attr":{"type":"command","ns":"admin.$cmd","command":{"serverStatus":1,"repl":1,"metrics":{"document":true,"cursor":true,"queryExecutor":true,"apiVersions":false,"aggStageCounters":false,"commands":false,"dotsAndDollarsFields":false,"getLastError":false,"mongos":false,"operation":false,"operatorCounters":false,"query":false,"record":false,"repl":false,"storage":false,"ttl":false},"lsid":{"id":{"$uuid":"da2858cb-2a55-42b5-b829-8a5aa20855f1"}},"$db":"admin"},"numYields":0,"reslen":32617,"locks":{"FeatureCompatibilityVersion":{"acquireCount":{"r":3}},"Global":{"acquireCount":{"r":3}}},"storage":{},"protocol":"op_msg","durationMillis":3}}

this is the logs when a add search ::

mongo_1        | {"t":{"$date":"2025-03-04T12:52:47.003+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn2","msg":"Slow query","attr":{"type":"command","ns":"admin.$cmd","command":{"serverStatus":1,"repl":1,"metrics":{"document":true,"cursor":true,"queryExecutor":true,"apiVersions":false,"aggStageCounters":false,"commands":false,"dotsAndDollarsFields":false,"getLastError":false,"mongos":false,"operation":false,"operatorCounters":false,"query":false,"record":false,"repl":false,"storage":false,"ttl":false},"lsid":{"id":{"$uuid":"da2858cb-2a55-42b5-b829-8a5aa20855f1"}},"$db":"admin"},"numYields":0,"reslen":32617,"locks":{"FeatureCompatibilityVersion":{"acquireCount":{"r":3}},"Global":{"acquireCount":{"r":3}}},"storage":{},"protocol":"op_msg","durationMillis":2}}
server-v5.0_1  | MongoError:  invalid flag in regex options: g
server-v5.0_1  |     at MessageStream.messageHandler (/usr/src/app/node_modules/mongodb/lib/cmap/connection.js:299:20)
server-v5.0_1  |     at MessageStream.emit (events.js:400:28)
server-v5.0_1  |     at MessageStream.emit (domain.js:475:12)
server-v5.0_1  |     at processIncomingData (/usr/src/app/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
server-v5.0_1  |     at MessageStream._write (/usr/src/app/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
server-v5.0_1  |     at writeOrBuffer (internal/streams/writable.js:358:12)
server-v5.0_1  |     at MessageStream.Writable.write (internal/streams/writable.js:303:10)
server-v5.0_1  |     at TLSSocket.ondata (internal/streams/readable.js:731:22)
server-v5.0_1  |     at TLSSocket.emit (events.js:400:28)
server-v5.0_1  |     at TLSSocket.emit (domain.js:475:12)
server-v5.0_1  |     at addChunk (internal/streams/readable.js:293:12)
server-v5.0_1  |     at readableAddChunk (internal/streams/readable.js:267:9)
nginx_1        | 172.17.0.2 - - [04/Mar/2025:12:52:51 +0000] "GET /v5.0/forest-admin/api/forest/drivers?timezone=Europe%2FParis&fields%5Bdrivers%5D=createdCountryFlag%2Cfullname%2CcreatedCity%2CdriverVehicleTypeEnum%2CdriverStatus%2CdriverTaxiNumber%2Cemail%2CdriverVehicleTypeIcon%2CphoneNumber%2CcreatedAt%2ClastLoginAt%2CisDriverAvailable%2CdriverProfileCompleted%2CsessionMode%2CisDriverLead%2CdriverShortId%2CturnOver&fields%5BturnOver%5D=_id&isSearchExtended=false&page%5Bnumber%5D=1&page%5Bsize%5D=30&search=thomas&searchExtended=0&sort=id HTTP/1.1" 500 507 "https://app.forestadmin.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36"
server-v5.0_1  |     at TLSSocket.Readable.push (internal/streams/readable.js:206:10)
server-v5.0_1  |     at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)
server-v5.0_1  |     at TLSWrap.callbackTrampoline (internal/async_hooks.js:130:17)
server-v5.0_1  | 2025-03-04T12:52:51.567Z - info: GET /v5.0/forest-admin/api/forest/drivers?timezone=Europe%2FParis&fields%5Bdrivers%5D=createdCountryFlag%2Cfullname%2CcreatedCity%2CdriverVehicleTypeEnum%2CdriverStatus%2CdriverTaxiNumber%2Cemail%2CdriverVehicleTypeIcon%2CphoneNumber%2CcreatedAt%2ClastLoginAt%2CisDriverAvailable%2CdriverProfileCompleted%2CsessionMode%2CisDriverLead%2CdriverShortId%2CturnOver&fields%5BturnOver%5D=_id&isSearchExtended=false&page%5Bnumber%5D=1&page%5Bsize%5D=30&search=thomas&searchExtended=0&sort=id 500 35ms
mongo_1        | {"t":{"$date":"2025-03-04T12:52:54.002+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn2","msg":"Slow query","attr":{"type":"command","ns":"admin.$cmd","command":{"serverStatus":1,"repl":1,"metrics":{"document":true,"cursor":true,"queryExecutor":true,"apiVersions":false,"aggStageCounters":false,"commands":false,"dotsAndDollarsFields":false,"getLastError":false,"mongos":false,"operation":false,"operatorCounters":false,"query":false,"record":false,"repl":false,"storage":false,"ttl":false},"lsid":{"id":{"$uuid":"da2858cb-2a55-42b5-b829-8a5aa20855f1"}},"$db":"admin"},"numYields":0,"reslen":32617,"locks":{"FeatureCompatibilityVersion":{"acquireCount":{"r":3}},"Global":{"acquireCount":{"r":3}}},"storage":{},"protocol":"op_msg","durationMillis":1}}
mongo_1        | {"t":{"$date":"2025-03-04T12:52:58.003+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn2","msg":"Slow query","attr":{"type":"command","ns":"admin.$cmd","command":{"serverStatus":1,"repl":1,"metrics":{"document":true,"cursor":true,"queryExecutor":true,"apiVersions":false,"aggStageCounters":false,"commands":false,"dotsAndDollarsFields":false,"getLastError":false,"mongos":false,"operation":false,"operatorCounters":false,"query":false,"record":false,"repl":false,"storage":false,"ttl":false},"lsid":{"id":{"$uuid":"da2858cb-2a55-42b5-b829-8a5aa20855f1"}},"$db":"admin"},"numYields":0,"reslen":32617,"locks":{"FeatureCompatibilityVersion":{"acquireCount":{"r":3}},"Global":{"acquireCount":{"r":3}}},"storage":{},"protocol":"op_msg","durationMillis":1}}
m

The problem therefore comes from an incompatibility between the way in which Forest Admin (via Forest - Express - Mongoose) builds research requests and Mongodb expectations concerning the options of regular expressions. A correction requires the modification of the request so that it does not include the flag g. Do not hesitate to consult the documentation or the support of Forest Admin to see if other users have encountered the same problem and what solutions have been implemented.

Hello Forest Admin Support Team,

We are experiencing a critical issue with the search functionality in Forest Admin when using MongoDB (v5.0 and above, including 6.0). When a search is performed, the regex expression generated by forest‑express‑mongoose automatically includes the g (global) flag, which MongoDB no longer supports starting with version 5.0. As a result, our logs show the following error:

makefile

Copy

MongoError: invalid flag in regex options: g

Context:

  • Stack in use:
    • Forest Admin via forest‑express‑mongoose (version 9.5.6 with liana 6.7.2)
    • Node.js: using node:14-bullseye (ensuring Node 14.18.0+ compatibility)
    • MongoDB: version 6.0 (and above)

Thanks for all those details,

you mentionned

no recente release no update less 6 months.

But I understand that you have recently upgraded your mongodb version to 5.0 or above, which started triggering the issue, is that the case ?
You are expecting forest-express-mongoose to be compatible with mongodb versions 5.0 and up, is that correct ?

Hello, Mongodb forced the update in Mongo 6.
It is not our will.
Do you have you planned for a fix about : Invalid Flag in Regex Options: G ?
We can’t used some research and action on Forest.
Tks

I tried to come back to version 4 of Mongo on UAT and it does not work.

I really think it is linked to an update on your side which prevents us now from using the platform.

We do not have a way to act on communication between Mongoose and Forest-Admin.

Dear all,
I fix it on our side, we publish the update without option ‘g’

let regexFullCond = {
$regex: ^${escapeStringRegexp(_search)}$,
$options: “i”

Hello @Stephane_Evrard,
I’m glad that you have found a workaround. thanks for marking the thread as sovled.
I will see if we can fix it on the forest-express-mongoose as well.