-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Bug Description
Circular <include> tags cause an infinite loop when using the default (non-recursive) preprocess path. The process hangs forever, spamming "Processing XML include" messages until manually killed.
Reproduction
mkdir /tmp/circ-test && cd /tmp/circ-test && git init
echo '<include>b.txt</include>' > a.txt
echo '<include>a.txt</include>' > b.txt
echo '<include>a.txt</include>' > circular_python.prompt
timeout 10 pdd preprocess circular_python.prompt
# Process hangs, spams "Processing XML include" until timeout kills itRoot Cause
process_include_tags() in preprocess.py has a while prev_text != current_text convergence loop (line 295). The _seen set for cycle detection is only populated inside the if recursive: block (lines 272-274). In the non-recursive path, _seen is never updated, so the cycle check at line 226 (if resolved in _seen) never triggers.
The same issue exists in process_backtick_includes() (line 200-205).
Context
PR #528 (merged, fix for #521) added cycle detection for the recursive path. This is a follow-up — the non-recursive (default) path was not covered by that fix.
Expected Behavior
pdd preprocess should detect the circular include and raise a ValueError("Circular include detected: ...") instead of looping forever. Same behavior as the recursive path.