[DRIVERS-2138] Test that client side encryption errors are distinguishable Created: 01/Aug/19  Updated: 31/Mar/22

Status: Backlog
Project: Drivers
Component/s: None
Fix Version/s: None

Type: Spec Change Priority: Major - P3
Reporter: Shane Harvey Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Driver Changes: Needed

 Description   

The spec says:

All errors from the MongoClient to mongocryptd MUST be distinguished in some way (e.g. exception type) to make it easier for users to distinguish when a command fails due to auto encryption limitations.

All errors from the MongoClient interacting with the key vault collection MUST be distinguished in some way (e.g. exception type) to make it easier for users to distinguish when a command fails due to behind-the-scenes operations required for encryption or decryption.

I think we may be able to automate this check in the spec tests by introducing a new result.errorClass field. For example:

  - description: "$text unconditionally fails"
    clientOptions:
      autoEncryptOpts:
        kmsProviders:
          aws: {} # Credentials filled in from environment.
    operations:
      - name: find
        arguments:
          filter:
            { $text: { $search: "search text" } }
        result:
          errorContains: "Unsupported match expression operator for encryption"
          errorClass: "MongocryptdError"

Some valid error classes may be: MongocryptdError, KeyVaultError, LibmongocryptError.



 Comments   
Comment by Shane Harvey [ 01/Aug/19 ]

Here's a thought: should drivers use errorLabels to distinguish encryption errors? If so then we can just use errorLabelsContain to assert that errors are labelled properly.

Generated at Thu Feb 08 08:24:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.