Avoid appending the same metadata multiple times in appendClientMetadata()

XMLWordPrintableJSON

    • Needed
    • Hide

      Summary of necessary driver changes

      This PR prevents duplicate metadata from being appended.

      • Implement new prose tests and update implementations to prevent duplicate metadata from being appended to a MongoClient.

      If drivers have not implemented https://jira.mongodb.org/browse/DRIVERS-2985, it is recommended to implement this ticket and https://jira.mongodb.org/browse/DRIVERS-2985 at the same time.

      Commits for syncing spec/prose tests
      (and/or refer to an existing language POC if needed)

      Show
      Summary of necessary driver changes This PR prevents duplicate metadata from being appended. Implement new prose tests and update implementations to prevent duplicate metadata from being appended to a MongoClient. If drivers have not implemented https://jira.mongodb.org/browse/DRIVERS-2985 , it is recommended to implement this ticket and https://jira.mongodb.org/browse/DRIVERS-2985 at the same time. Commits for syncing spec/prose tests (and/or refer to an existing language POC if needed) https://github.com/mongodb/specifications/commit/e133c20e8d434f537f1e2f29e8753ad9aae2570a
    • $i18n.getText("admin.common.words.hide")
      Key Status/Resolution FixVersion
      CDRIVER-6089 Backlog
      CXX-3341 Backlog
      CSHARP-5721 Blocked
      GODRIVER-3653 In Code Review
      JAVA-5955 In Code Review 5.6.1
      NODE-7138 Fixed 6.20.0
      PYTHON-5526 Backlog
      PHPLIB-1718 Blocked
      RUBY-3704 Backlog
      RUST-2272 Fixed 3.4.0
      $i18n.getText("admin.common.words.show")
      #scriptField, #scriptField *{ border: 1px solid black; } #scriptField{ border-collapse: collapse; } #scriptField td { text-align: center; /* Center-align text in table cells */ } #scriptField td.key { text-align: left; /* Left-align text in the Key column */ } #scriptField a { text-decoration: none; /* Remove underlines from links */ border: none; /* Remove border from links */ } /* Add green background color to cells with FixVersion */ #scriptField td.hasFixVersion { background-color: #00FF00; /* Green color code */ } #scriptField td.willNotDo { background-color: #FF0000; /* Red color code */ } /* Center-align the first row headers */ #scriptField th { text-align: center; } Key Status/Resolution FixVersion CDRIVER-6089 Backlog CXX-3341 Backlog CSHARP-5721 Blocked GODRIVER-3653 In Code Review JAVA-5955 In Code Review 5.6.1 NODE-7138 Fixed 6.20.0 PYTHON-5526 Backlog PHPLIB-1718 Blocked RUBY-3704 Backlog RUST-2272 Fixed 3.4.0

      Summary

      As discussed in https://mongodb.slack.com/archives/C72LB5RPV/p1754510550358959, with the existing ClientMetadata appending API, some frameworks might instantiate objects with the same mongo client.  This would result in duplicated metadata for the same framework.

      We should somehow ensure that we only append client metadata if the new metadata has not already been appended to the client's metadata.

      Motivation

      Who is the affected end user?

      Driver engineers integrating with 3rd party libraries.

      How does this affect the end user?

      We might see duplicate framework entries in the server logs for the framework, depending on whether or not a client is shared across multiple framework abstractions.  (ex: the same MongoClient being used for multiple VectorStores in langchainjs might result in `langchainjs` being appending to the metadata multiple times).

      How likely is it that this problem or use case will occur?

      Pretty likely - I know we'll encounter this in langchainjs and it seems like the Python team has encountered this in their integrations as well.

      If the problem does occur, what are the consequences and how severe are they?

      unsure - I'm not sure how the analytics team parses handshake metadata but I'd want to confirm that this problem wouldn't result in duplicated analytics being reported.

      Is this issue urgent?

      not urgent.

      Is this ticket required by a downstream team?

      no.

      Is this ticket only for tests?

      no.

      Acceptance Criteria

      • Add spec language and tests to ensure that client metadata is only appended to the driver's existing metadata if the new metadata has not already been appended.
        • The spec change should allow appending metadata with a distinct version of a library for which metadata has already been captured (and have an explicit test for this case)

            Assignee:
            Bailey Pearson
            Reporter:
            Bailey Pearson
            Daria Pardue Daria Pardue
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: