Improve error message when using incompatible pymongocrypt version

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Unknown
    • 4.16.0
    • Affects Version/s: None
    • Component/s: None
    • 🔵 Done
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Reported in slack. This error occurs when using 4.2.0 with pymongocrypt < 1.3. The fix is to upgrade pymongocrypt too:

      I have just upgraded to the 4.2.0 driver and I now get an error with CSFLE when creating DEKs:

      Traceback (most recent call last):
        File "/opt/homebrew/lib/python3.9/site-packages/pymongo/encryption.py", line 76, in _wrap_encryption_errors
          yield
        File "/opt/homebrew/lib/python3.9/site-packages/pymongo/encryption.py", line 622, in create_data_key
          return self._encryption.create_data_key(
      TypeError: create_data_key() got an unexpected keyword argument 'key_material'
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/Users/brett.gray/Documents/Dev/Crypt/csfle_6.py", line 335, in <module>
          main()
        File "/Users/brett.gray/Documents/Dev/Crypt/csfle_6.py", line 225, in main
          employee_key_id, err = get_employee_key(client, kms_provider, provider, namespace, employee["dekAltName"])
        File "/Users/brett.gray/Documents/Dev/Crypt/csfle_6.py", line 158, in get_employee_key
          employee_key_id = client_encryption.create_data_key(kms_provider=p, master_key=master_key, key_alt_names=str(id))
        File "/opt/homebrew/lib/python3.9/site-packages/pymongo/encryption.py", line 622, in create_data_key
          return self._encryption.create_data_key(
        File "/opt/homebrew/Cellar/python@3.9/3.9.13_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
          self.gen.throw(typ, value, traceback)
        File "/opt/homebrew/lib/python3.9/site-packages/pymongo/encryption.py", line 82, in _wrap_encryption_errors
          raise EncryptionError(exc)
      pymongo.errors.EncryptionError: create_data_key() got an unexpected keyword argument 'key_material'
      

      This did not occur with 4.1.1
      Any ideas why the key_material is causing issues if I am not declaring it and it is optional?
      ...
      Wan helped me with this, I needed to upgrade pymongocrypt to 1.3.0.

      We should make these kinda of errors easier to debug. The problem is that pip does not warn about dependency conflicts for optional deps like pymongocrypt.

            Assignee:
            Steve Silvester
            Reporter:
            Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: