From ef1c6824163cfb18615f10701e6b94b6f54c2a10 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Thu, 19 Sep 2024 14:32:40 -0500 Subject: [PATCH] MongoClient(uuid_representation=) has to be a string The UuidRepresentation enum has integer values. pymongo converts the string into the enum instance. --- st2common/st2common/models/db/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/st2common/st2common/models/db/__init__.py b/st2common/st2common/models/db/__init__.py index db4b657132..c29e217907 100644 --- a/st2common/st2common/models/db/__init__.py +++ b/st2common/st2common/models/db/__init__.py @@ -56,7 +56,6 @@ import ssl as ssl_lib import six -from bson.binary import UuidRepresentation from oslo_config import cfg import mongoengine from mongoengine.queryset import visitor @@ -195,7 +194,7 @@ def _db_connect( # TODO: Add uuid_representation option in st2.conf + a migration guide/script. # This preserves the uuid handling from pymongo 3.x, but it is not portable: # https://pymongo.readthedocs.io/en/stable/examples/uuid.html#handling-uuid-data-example - uuid_representation = UuidRepresentation.PYTHON_LEGACY + uuid_representation = "pythonLegacy" connection = mongoengine.connection.connect( # kwargs are defined by mongoengine and pymongo.MongoClient: