Skip to content

fix(di): prevent exception when removing unresolved probe [backport 2.21] #13385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: 2.21
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ddtrace/debugging/_probe/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ def log_probes_status(self) -> None:
self._log_probe_status_unlocked(entry)

def _remove_pending(self, probe: Probe) -> None:
location = _get_probe_location(probe)

# Pending probes must have valid location information
assert location is not None, probe # nosec
if (location := _get_probe_location(probe)) is None:
# If the probe has no location information, then it cannot be
# pending.
return

pending_probes = self._pending[location]
try:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
dynamic instrumentation: prevent an exception when trying to remove a probe
that did not resolve to a valid source code location.
3 changes: 3 additions & 0 deletions tests/debugging/probe/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def test_registry_location_error():
# Check that the probe is not pending
assert not registry.get_pending(__file__)

# Check that unregistering the probe does not cause an exception
registry.unregister(probe)

# Check that we emitted the correct diagnostic error message
for e in status_logger.queue:
del e["timestamp"]
Expand Down
Loading