-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Unknown
-
None
-
Affects Version/s: 5.0.0
-
Component/s: Client Side Encryption
-
None
-
Java Drivers
Summary
The AutoEncryptionSettings.builder() has support for supplying a value to the .encryptedFieldsMap property. But setting this value when you using Automatic Encryption creates an error about the keyId value.
Specifically setting the keyId to an instance of BsonNull() produces an error of
Caused by: com.mongodb.crypt.capi.MongoCryptException: expected 'fields.keyId' to be type binary, got: 10
Omitting the keyId field produces this error.
Caused by: com.mongodb.crypt.capi.MongoCryptException: unable to find 'keyId' in 'field' document
This is using 5.0.0 over the driver and associated libraries.
This was tested against a local copy of Enterprise Advanced 7.0 configured for a single node replica set.
How to Reproduce
The full code to test this exists at this Github repo.
github.com:jesmith17/mongodb-sprint-zero.git. Execute the java-sample project. It can be run using the command
mvn spring-boot:run
To create the issues simply uncomment line 174 of class MongoDBConnection.java. This will set the field on the AutomaticEncryptionSettings and create the error.
To produce the second error above, comment out the keyId fields in lines 139, 143, and 147
The existence of this property .encryptedFieldsMap as part of the AutomaticEncryptionSettings object does make any sense. If there is no way to set it to valid values, and if the fieldMap is only required client side in a case of using explicit encryption. then the field should be removed to not cause confusion.