-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Client Side Encryption schema error with MongoDB driver 4.3+ #3929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@jyemin any changes you are aware of that may be related to this? |
I'm not aware of anything in the driver. And it's strange because there is nothing I can see in the provided schema that corresponds to the error message (which is coming from the server, not the driver). If we can get a minimal reproducible example, we can take a closer look. |
I can create an example application no problem. |
So here is the example. In build.gradle, the version property downgrades the driver to 4.2.3. When I remove it or set it to a newer version, I get the exception. https://github.com/rainerfrey-inxmail/spring-data-momgodb-csfle-example |
@rainerfrey-inxmail thanks for the example application. I'm still investigating, but one thing that I'm seeing that's different: even with the 4.2.3 driver I see the same exception. Can you confirm that when you run this application as is, with 4.2.3, you don't get the exception? Try dropping the collection in the database prior to running the example, to ensure you're starting with a clean slate. |
I can reproduce the issue, using the provided sample application. Here's what's happening:
@rainerfrey-inxmail to work around the issue, I suggest that you tack on For the Spring team, I suggest that
Assuming that's feasible, it will avoid the UUID encoding issue entirely. |
@rainerfrey-inxmail one other thing I found: there was a change in 4.3.0 that does affect the behavior of your application, though not in the way that you reported. With 4.2.3, I get the following exception:
With 4.3.0, I don't get that exception. This is due to the fact that 4.3.0 includes a fix for https://jira.mongodb.org/browse/JAVA-4140. However, I don't think it's directly relevant to your findings, since this exception is due to the log statement in
|
@jyemin thank you so much for the investigation and the suggested workaround, I will apply this today. With driver 4.2.3 I neither get the original exception, nor the CodecConfigurationException from your later comment. I'm running the application as is, just with MongoDB and key configured in application.yml. There is no exception output, and the collection is created with the schema validator option. ICTM I'm using Java 17.
|
To avoid driver configuration specific UUID representation format errors (binary subtype 3 vs. subtype 4) we now directly convert the given key into its subtype 4 format. Resolves: #3929
I can confirm that setting the uuid representation to standard solves the issue with driver 4.4.0. |
Hi,
there seems to be an incompatibility with the generated validation schema with encrypted properties and newer driver versions.
I have the following entity class, and use
MongoJsonSchemaCreator
to create the schema:This creates the following schema:
With driver version 4.3.4 and newer (didn't test 4.3.0-4.3.3), when creating a collection with this schema, I receive the following exception:
With driver version 4.2.3 it works.
I'm not sure whether this is to be considered a bug in newer driver versions, or an incompatible but intended change that Spring Data MongoDB needs to adapt to. I'm using Spring Data MongoDB 3.3.0 in a Spring Boot 2.6.2 application.
I'm not familiar with the MongoDB driver code base but when looking through issues implemented in 4.3.x I came across this one that I assume could be related:
https://jira.mongodb.org/browse/JAVA-4140
This occurs with MongoDB Atlas versions 4.4 and 5.0.
The text was updated successfully, but these errors were encountered: