...
This regression will break all users of PyMongo who are using Python 3 as Python 3 uses the u option by default. This regression was discovered when a PyMongo test started failing with the error: pymongo.errors.OperationFailure: invalid flag in regex options: u, full error: {'ok': 0.0, 'errmsg': ' invalid flag in regex options: u', 'code': 51108, 'codeName': 'Location51108', '$clusterTime': {'clusterTime': Timestamp(1621462192, 5), 'signature': {'hash': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 'keyId': 0}}, 'operationTime': Timestamp(1621462192, 5)} Server version: db version v5.0.0-alpha0-475-g96d00d9 Build Info: { "version": "5.0.0-alpha0-475-g96d00d9", "gitVersion": "96d00d92d71ed9ddc0ac4eb3f60b0b27cb9dcb34", "modules": [ "enterprise" ], "allocator": "system", "environment": { "distarch": "x86_64", "target_arch": "x86_64" } } While the $regex operator documentation does not list u as a supported option, this was working until now.
mickey.winters commented on Wed, 23 Jun 2021 15:06:09 +0000: my plan right now is for this ticket to get fixed by fixing 26991 kyle.suarez commented on Wed, 23 Jun 2021 15:05:40 +0000: Hi prashant.mital, the behavior here is a regression in the SBE engine, which has since been turned off by default in SERVER-57758. We are still working on fixing this for SBE, but since this is no longer a bug in the 5.0 release, I am changing the fix version from "5.0 Required" to "Backlog" as it is not a release blocker. CC server-release mickey.winters commented on Mon, 7 Jun 2021 17:43:32 +0000: Inconsistency between SBE and Classic Engines is going to be resolved by SERVER-57079. so that both ignore unsupported options, however this will still be inconsistent with aggregation ignoring unsupported options. anton.korshunov commented on Fri, 28 May 2021 08:56:24 +0000: This is a regression in the SBE engine: db.coll.find({a: /a/u}) Error: error: { "ok" : 0, "errmsg" : " invalid flag in regex options: u", "code" : 51108, "codeName" : "Location51108" } db.adminCommand({setParameter: 1, internalQueryForceClassicEngine: true}) { "was" : false, "ok" : 1 } db.coll.find({a: /a/u}) The error is coming from flagsToPcreOptions. It takes an argument to indicate whether unknown options should be ignored or not. In the classic engine this argument is set to true when we construct a RegexMatchExpression and to false when we construct an aggregate ExpressionRegex. However, in SBE we use the same sbe::PcreRegex value and built-in VM functions both for match and aggregate regex expressions where we set the flag to false. Sending this ticket to QE for re-triaging. behackett commented on Thu, 27 May 2021 23:03:59 +0000: Note that Python regular expressions support all the options listed in the BSON spec, so the server should continue to ignore anything the BSON spec documents but the server does not itself support rather than returning an error. behackett commented on Thu, 27 May 2021 23:02:17 +0000: Or if not strictly supported (I have no idea if PCRE even supports a unicode option) at least continue to be silently ignored. prashant.mital commented on Thu, 20 May 2021 17:25:38 +0000: CC: behackett prashant.mital commented on Thu, 20 May 2021 17:24:57 +0000: As per the BSON spec: Regular expression - The first cstring is the regex pattern, the second is the regex options string. Options are identified by characters, which must be stored in alphabetical order. Valid options are 'i' for case insensitive matching, 'm' for multiline matching, 'x' for verbose mode, 'l' to make \w, \W, etc. locale dependent, 's' for dotall mode ('.' matches everything), and 'u' to make \w, \W, etc. match unicode. So the u option should definitely be supported by the server.
Connect to a RS running version of MongoDB mentioned above using PyMongo 3.11.4 from pymongo import MongoClient client = MongoClient(directConnection=False) Insert the following document: client.db.test.insert_one({"x": "hello_test"}) Run the following find operation: import re client.db.test.find({"x": re.compile("^hello.*")}))), 4)