Commit e161ee3
committed
Allow breakpoint() and input() through the sandbox in debug_mode
The workflow sandbox restricts the `breakpoint` and `input` builtins
as non-deterministic. With debug_mode set the user has explicitly opted
into single-stepping (and hence non-determinism for the duration of the
debug session), so calling breakpoint() in sandboxed workflow code
should reach the debugger rather than raising a
RestrictedWorkflowAccessError.
Adds a `_relax_sandbox_for_debugger` helper that, when debug_mode is
enabled and the runner is a SandboxedWorkflowRunner, rebuilds the
restrictions with `breakpoint` and `input` removed from the
`__builtins__` invalid-module-members set. Other restrictions are
untouched - this is a targeted relaxation, not full sandbox bypass.
Together with the existing dispatch fix (which moves activation onto
the main asyncio thread under debug_mode) this means a user can drop
`breakpoint()` into any workflow - sandboxed or not - and get an
interactive pdb prompt without swapping to UnsandboxedWorkflowRunner.
Adds test_breakpoint_works_in_sandboxed_workflow_in_debug_mode which
exercises the full path: sandboxed workflow + breakpoint() + worker
hook + main-thread placement. The test substitutes the captured
_ORIGINAL_BREAKPOINTHOOK with a stub so CI doesn't try to drive a real
pdb REPL.
4/4 tests pass on Python 3.13 and 3.14 locally. No regressions in
tests/worker/test_worker.py.1 parent f0bc1ae commit e161ee3
2 files changed
Lines changed: 105 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
74 | 111 | | |
75 | 112 | | |
76 | 113 | | |
| |||
119 | 156 | | |
120 | 157 | | |
121 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
122 | 168 | | |
123 | 169 | | |
124 | 170 | | |
| |||
150 | 196 | | |
151 | 197 | | |
152 | 198 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 199 | + | |
| 200 | + | |
158 | 201 | | |
159 | 202 | | |
160 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
90 | 147 | | |
91 | 148 | | |
92 | 149 | | |
| |||
0 commit comments