Skip to content

Commit d4f84f7

Browse files
github-actions[bot]quinna-herikayasuda
authored
fix(pymongo): add pin type check [backport 2.15] (#11230)
Backport f3b5275 from #11145 to 2.15. Small type check fix for expected `Pin` type to unblock #11041 ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) --------- Co-authored-by: Quinna Halim <[email protected]> Co-authored-by: erikayasuda <[email protected]>
1 parent 6f2c14d commit d4f84f7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

ddtrace/contrib/internal/pymongo/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ def _trace_topology_select_server(func, args, kwargs):
103103
# Ensure the pin used on the traced mongo client is passed down to the topology instance
104104
# This allows us to pass the same pin in traced server objects.
105105
topology_instance = get_argument_value(args, kwargs, 0, "self")
106-
ddtrace.Pin.get_from(topology_instance).onto(server)
106+
pin = ddtrace.Pin.get_from(topology_instance)
107+
108+
if pin is not None:
109+
pin.onto(server)
107110
return server
108111

109112

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
fixes:
3+
- |
4+
pymongo: Adds type checking to solve an issue where ``NoneType`` instead of expected ``Pin`` object would throw an error in ``TracedTopology`` method.

0 commit comments

Comments
 (0)