Repository navigation
fix(functions): keep an attached debugger's breakpoints working on Python < 3.12 - #2000
Open
RaresUiPath wants to merge 1 commit into
Open
RaresUiPath wants to merge 1 commit into
RaresUiPath wants to merge 1 commit into
Conversation
…thon < 3.12 The functions debug runtime runs a function on a worker thread with its own sys.settrace hook whenever the entrypoint has a call graph, to emit state events, even when no breakpoints are set. Before Python 3.12, pydevd-based debuggers such as debugpy trace threads through sys.settrace too, so with `uipath run --debug` the runtime replaced the debugger's hook on that thread: breakpoints were verified but never hit, and debugpy warned that sys.settrace() should not be used while debugging. Without breakpoints of our own, skip the call-graph state events while a pydevd trace function is active, so the function runs in the thread the debugger traces. Breakpoints requested through the debug bridge keep the current behavior, and nothing changes from Python 3.12, where debugpy uses sys.monitoring, or under coverage tools. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the attached-debugger tracing change.
No open issues 🎉
What changed in this PR
Preserves attached pydevd-based debugger breakpoints on Python versions before 3.12 by avoiding the SDK’s trace hook when no debug-bridge breakpoints are requested.
Changes:
- Skips call-graph state tracing when a pydevd tracer is active, while retaining debug-bridge breakpoint behavior.
- Adds regression tests for debugger tracing, breakpoint pauses, state-event suppression, and tracer detection.
- Bumps
uipathto version 2.15.3.
| File | Description |
|---|---|
packages/uipath/uv.lock |
Updates the locked local package version to 2.15.3. |
packages/uipath/tests/functions/test_debug_breakpoints.py |
Adds attached-debugger regression tests. |
packages/uipath/src/uipath/functions/debug.py |
Detects pydevd tracers and bypasses optional call-graph tracing. |
packages/uipath/pyproject.toml |
Bumps the package version to 2.15.3. |
Review effort: Balanced
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
On Python 3.11, breakpoints in a function are never hit when it runs with
uipath run --debugand VS Code attaches with "Python: Remote Attach" (debugpy). The breakpoint shows as verified, the function runs to the end, and debugpy prints:Cause
UiPathDebugFunctionsRuntime.stream()runs the function on a worker thread with its ownsys.settracehook whenever the entrypoint has a call graph. It does this to emit state events for the graph nodes, even when no breakpoints are set. Before Python 3.12, pydevd-based debuggers such as debugpy also trace threads throughsys.settrace, so our hook replaces the debugger's on that thread. From Python 3.12, debugpy usessys.monitoringand isn't affected.Fix
If no breakpoints were requested and the current thread is traced by a pydevd-based debugger, skip the call-graph state events. The function then runs without our trace function, in the thread the debugger already traces.
sys.gettrace()is empty under debugpy.pytest --covkeep today's behavior.The local
runcommand forwards onlyUPDATEDstate events, so it loses nothing. A debug bridge that renders the call graph won't get per-function events while a settrace-based debugger is attached.Testing
TestAttachedDebuggertests intests/functions/test_debug_breakpoints.py:pytest tests/functions: 65 passed.uipathpackage suite on Python 3.11: 2735 passed. One local failure,test_new.py::TestUipathScaffoldPin, comes from older installeduipathmetadata in the local environment and is unrelated.uipath run main '{"n": 21}' --debugwith a breakpoint in a helper that the entrypoint calls.ruff check,ruff format --checkandmypypass on the changed files.Bumps
uipathto 2.15.3.🤖 Generated with Claude Code