MongoOptionsExtension copy constructor drops CryptExtraOptions and QueryableEncryptionSchemaMode

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 10.0.3, 9.1.3, 8.4.3
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Dotnet Drivers
    • Needed
    • None
    • None
    • None
    • None
    • None
    • None

      The MongoOptionsExtension copy constructor (MongoOptionsExtension(MongoOptionsExtension copyFrom)) copies most configuration fields (ConnectionString, ClientSettings, MongoClient, DatabaseName, CryptProvider, CryptProviderPath, KeyVaultNamespace, KmsProviders, QueryMode) but omits two: CryptExtraOptions and QueryableEncryptionSchemaMode.

      Because every With* method clones via this copy constructor, chaining any With* call after one that set those fields silently loses them.

      Repro

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      var ext = new MongoOptionsExtension()
          .WithCryptProvider(provider, extraOptions: someExtraOptions)  // sets CryptExtraOptions
          .WithQueryMode(MongoQueryMode.DriverLinq);                    // clones via copy ctor -> CryptExtraOptions LOST
      // ext.CryptExtraOptions is now null
      

      Same for QueryableEncryptionSchemaMode set via WithQueryableEncryptionSchemaMode(...) followed by any other With*.

      Impact

      Silent loss of Queryable Encryption configuration (extra crypt options + schema mode) depending on the order of fluent option calls — a data-fidelity / config-correctness bug in the encryption surface.

      Fix

      • Add CryptExtraOptions = copyFrom.CryptExtraOptions; and QueryableEncryptionSchemaMode = copyFrom.QueryableEncryptionSchemaMode; to the copy constructor.
      • Add a clone-fidelity round-trip test asserting that every field survives an arbitrary chain of With* calls (guards against future omissions).

      Notes

      • Pre-existing — the omission exists on main and predates the native-query work (EF-322/EF-323/EF-329/EF-331). Found during the EF-331 code review. Should be fixed on its own branch off main, not folded into the native-query stack.

            Assignee:
            Arthur Vickers
            Reporter:
            Arthur Vickers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: