Skip to content

Unable to Create Encrypted Collection with Floating Point Range (precision, min, max not respected) #4989

Closed
@ricardohsmello

Description

@ricardohsmello

Hi team,

I’ve been working with Spring Data MongoDB 4.5.0 and the new support for Queryable Encryption, and I’m encountering an issue when trying to create an encrypted collection with a double field using range encryption.

Here’s the code snippet:

    private static void manualCollectionSetup(ClientEncryption clientEncryption, MongoOperations mongoTemplate) {
        BsonBinary dkSalary = clientEncryption.createDataKey("local", new com.mongodb.client.model.vault.DataKeyOptions().keyAltNames(List.of("salary")));

        CollectionOptions collectionOptions = CollectionOptions.encryptedCollection(options -> options
                .queryable(encrypted(float64("salary")).algorithm("Range").keyId(dkSalary.asUuid()), range().contention(0).precision(2).min(0.0).max(9999.0))
        );

        mongoTemplate.createCollection(Employee.class, collectionOptions);
    }

I'm getting:

Caused by: com.mongodb.MongoCommandException: Command failed with error 6967100 (Location6967100): 'Precision, min, and max must all be specified together for floating point fields' on server localhost:27020. The full response is {"ok": 0.0, "errmsg": "Precision, min, and max must all be specified together for floating point fields", "code": 6967100, "codeName": "Location6967100"}

I believe this suggests that the Spring Data is not sending these parameters (precision, min, max) properly when creating the collection for floating point fields.

I’m happy to share a full minimal reproducible example if needed.

Thank you for the help!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions