temporalio/sdk-python
Missing comma in sandbox restrictions leaves time.perf_counter_ns and process_time unrestricted
Summary
Context: The workflow sandbox in
temporalio/worker/workflow_sandbox/_restrictions.pydefines whichtimemodule functions are restricted during workflow execution to ensure deterministic behavior.Bug: A missing comma between two strings on line 788 causes Python’s implicit string concatenation to merge
"perf_counter_ns"and"process_time"into a single invalid entry"perf_counter_nsprocess_time".Actual vs. expected: The restrictions set contains the invalid concatenated string instead of two separate entries, leaving
time.perf_counter_nsandtime.process_timeunrestricted when they should triggerRestrictedWorkflowAccessErrorat runtime.Impact: Workflows can call non-deterministic time measurement functions without restriction, violating workflow determinism guarantees.
Code with bug
Example
Python’s implicit string concatenation merges adjacent string literals when no comma separates them:
Test output confirms the bug:
Both time.perf_counter_ns() and time.process_time() are real Python functions that return non-deterministic values based on system state and timing.
Recommended fix
Add a comma between the two strings: