Avoid appending the same metadata multiple times in appendClientMetadata()

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Component/s: Handshake, Networking
    • None
    • Needed

      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 metatdata 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

      • ensure that client metadata is only appended to the driver's existing metadata if the new metadata has not already been appended.

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

                Created:
                Updated: