diff --git a/packages/syft/src/syft/service/network/node_peer.py b/packages/syft/src/syft/service/network/node_peer.py index 6711e5480d9..d28c14d693b 100644 --- a/packages/syft/src/syft/service/network/node_peer.py +++ b/packages/syft/src/syft/service/network/node_peer.py @@ -18,6 +18,7 @@ from ...types.datetime import DateTime from ...types.syft_migration import migrate from ...types.syft_object import PartialSyftObject +from ...types.syft_object import SYFT_OBJECT_VERSION_1 from ...types.syft_object import SYFT_OBJECT_VERSION_2 from ...types.syft_object import SYFT_OBJECT_VERSION_3 from ...types.syft_object import SyftObject @@ -321,11 +322,11 @@ def delete_route( class NodePeerUpdate(PartialSyftObject): - id: UID + __canonical_name__ = "NodePeerUpdate" + __version__ = SYFT_OBJECT_VERSION_1 + name: str - verify_key: SyftVerifyKey node_routes: list[NodeRouteType] - node_type: NodeType admin_email: str ping_status: NodePeerConnectionStatus ping_status_message: str diff --git a/packages/syft/src/syft/store/mongo_document_store.py b/packages/syft/src/syft/store/mongo_document_store.py index fa38d6c1ba8..59d6799c2bb 100644 --- a/packages/syft/src/syft/store/mongo_document_store.py +++ b/packages/syft/src/syft/store/mongo_document_store.py @@ -357,17 +357,17 @@ def _update( if has_permission or self.has_permission( ActionObjectWRITE(uid=prev_obj.id, credentials=credentials) ): - # we don't want to overwrite Mongo's "id_" or Syft's "id" on update - obj_id = obj["id"] + for key, value in obj.to_dict(exclude_empty=True).items(): + # we don't want to overwrite Mongo's "id_" or Syft's "id" on update + if key == "id": + # protected field + continue - # Set ID to the updated object value - obj.id = prev_obj["id"] + # Overwrite the value if the key is already present + setattr(prev_obj, key, value) # Create the Mongo object - storage_obj = obj.to(self.storage_type) - - # revert the ID - obj.id = obj_id + storage_obj = prev_obj.to(self.storage_type) try: collection.update_one(