Skip to content

jobflow admin upgrade fails - BSON error #299

@msiron-entalpic

Description

@msiron-entalpic

Command:
jf admin upgrade

Returns:

The selected project is AWS_DFT from config file /home/martin_siron/.jfremote/AWS_DFT.yaml
/home/martin_siron/software/entalcat/.venv/lib/python3.11/site-packages/maggma/stores/mongolike.py:501: UserWarning: You appear to be connected to a DocumentDB cluster. For more information regarding feature compatibility and support please visit https://www.mongodb.com/supportability/documentdb
  conn: MongoClient = MongoClient(self.uri, **self.mongoclient_kwargs)
/home/martin_siron/software/entalcat/.venv/lib/python3.11/site-packages/maggma/stores/mongolike.py:111: UserWarning: You appear to be connected to a DocumentDB cluster. For more information regarding feature compatibility and support please visit https://www.mongodb.com/supportability/documentdb
  MongoClient(
/home/martin_siron/software/entalcat/.venv/lib/python3.11/site-packages/maggma/stores/gridfs.py:147: UserWarning: You appear to be connected to a DocumentDB cluster. For more information regarding feature compatibility and support please visit https://www.mongodb.com/supportability/documentdb
  MongoClient(
An Error occurred during the command execution: OperationFailure Failed to parse update: field must be of BSON type object, full error: {'ok': 0.0, 'code': 9, 'errmsg': 'Failed 
to parse update: field must be of BSON type object', 'operationTime': Timestamp(1747902153, 1)}

Debugging:
Using breakpoint I've identified that the error comes at the following line in utils/db.py

while True:
            result = self.collection.find_one_and_update(
                db_filter,
                update,
                upsert=False,
                return_document=ReturnDocument.AFTER,
                **self.kwargs,
            )

The issue appears that update is a list rather than a dictionary.
[{'$set': {'lock_id': {'$cond': {'if': {'$gt': ['$lock_id', None]}, 'then': '$lock_id', 'else': '415216cb-4eac-4153-8300-aa4bef591e29'}}, 'lock_time': {'$cond': {'if': {'$gt': ['$lock_id', None]}, 'then': '$lock_time', 'else': datetime.datetime(2025, 5, 22, 8, 24, 14, 987800)}}}}]

Indeed, changing update to update[0] in the collection.find_one_and_update() line appears to go through with no error, but leads to downstream errors when attempting to start the runner.

Details:
jobflow-remote version 0.1.6
maggma version: 0.71.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions