Avoid appending the same metadata multiple times in appendClientMetadata()

XMLWordPrintableJSON

    • Needed
    • Hide

      Summary of necessary driver changes

      •  

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

      •  

      Context for other referenced/linked tickets

      •  
      Show
      Summary of necessary driver changes   Commits for syncing spec/prose tests (and/or refer to an existing language POC if needed)   Context for other referenced/linked tickets  
    • $i18n.getText("admin.common.words.hide")
      Key Status/Resolution FixVersion
      CDRIVER-6089 Blocked
      CXX-3341 Blocked
      CSHARP-5721 Blocked
      GODRIVER-3653 Blocked
      JAVA-5955 Blocked
      NODE-7138 In Code Review
      PYTHON-5526 Blocked
      PHPLIB-1718 Blocked
      RUBY-3704 Blocked
      RUST-2272 Blocked
      $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 Blocked CXX-3341 Blocked CSHARP-5721 Blocked GODRIVER-3653 Blocked JAVA-5955 Blocked NODE-7138 In Code Review PYTHON-5526 Blocked PHPLIB-1718 Blocked RUBY-3704 Blocked RUST-2272 Blocked

      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: