arunbandari / mongo-gui

A web-based MongoDB graphical user interface
http://20.106.238.56:4321/
MIT License
290 stars 87 forks source link

MongoError: can't get regex from filter doc #87

Closed warren-bank closed 1 year ago

warren-bank commented 2 years ago

Hi. Great project!

I just signed up for a mongodb.com free tier account. I installed your server and tried to connect to this DB, but nothing was working.. and it was displaying error messages.

The network tab showed that this request:

  http://localhost/databases?includeCollections=true

was returning:

  400 Bad Request
  MongoError: can't get regex from filter doc Error parsing value [{$not [{$regex {"pattern": "system.+$", "options": ""}}]}] to RegEx: Must specify $regex field

This regex pattern is used in two places:

  1. listing databases with all associated collections
  2. listing collections for a single database

In both cases, I replaced:

  .listCollections({ name: { $not: { $regex: /system.+$/ } } }).toArray()

with:

  .listCollections().toArray()

..and now the server works properly.

I don't know if this cloud service is a special case.. but I just wanted to make a PSA about this issue. Would it be worth considering a cli option to prevent using this regex filter? ex: mongo-gui --all-collections -p 80 -u ...

warren-bank commented 2 years ago

Windows 7 SP1 node v16.14.0 mongodb v5.0.6 mongo-gui v0.0.17

vidyasagar-m commented 1 year ago

fixed.