From 759a6bb58d8f456e0572c48d31a875f05a617a69 Mon Sep 17 00:00:00 2001 From: Rion Bora <223810819+GoldenEmperor1177@users.noreply.github.com> Date: Thu, 22 Oct 2026 20:59:20 +0530 Subject: [PATCH] PYTHON-6146 Fix the rewrap_many_data_key example The example in the docstring of ClientEncryption.rewrap_many_data_key passed the provider inside master_key, which raises a ConfigurationError because no provider is given. Pass the provider as its own argument and use the fields of an Azure master key. --- pymongo/asynchronous/encryption.py | 9 ++++----- pymongo/synchronous/encryption.py | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pymongo/asynchronous/encryption.py b/pymongo/asynchronous/encryption.py index eca189a526..e4f91294a4 100644 --- a/pymongo/asynchronous/encryption.py +++ b/pymongo/asynchronous/encryption.py @@ -1176,12 +1176,11 @@ async def rewrap_many_data_key( client_encryption.rewrap_many_data_key( filter={"keyAltNames": "optional filter for which keys you want to update"}, + provider="azure", # replace with your cloud provider master_key={ - "provider": "azure", # replace with your cloud provider - "master_key": { - # put the rest of your master_key options here - "key": "" - }, + # put the rest of your master_key options here + "keyVaultEndpoint": "", + "keyName": "", }, ) diff --git a/pymongo/synchronous/encryption.py b/pymongo/synchronous/encryption.py index 1d9fae5888..1626c16f58 100644 --- a/pymongo/synchronous/encryption.py +++ b/pymongo/synchronous/encryption.py @@ -1169,12 +1169,11 @@ def rewrap_many_data_key( client_encryption.rewrap_many_data_key( filter={"keyAltNames": "optional filter for which keys you want to update"}, + provider="azure", # replace with your cloud provider master_key={ - "provider": "azure", # replace with your cloud provider - "master_key": { - # put the rest of your master_key options here - "key": "" - }, + # put the rest of your master_key options here + "keyVaultEndpoint": "", + "keyName": "", }, )