Description
pdd update <code_file> --output <path> crashes with NameError when the code file is in a subdirectory.
Reproduction
mkdir -p /tmp/pdd-test/backend/src
echo "def hello(): return 'world'" > /tmp/pdd-test/backend/src/module.py
cd /tmp/pdd-test && git init && git add -A && git commit -m "init"
pdd update backend/src/module.py --output /tmp/output/
Actual output
Error: cannot access local variable 'context_config' where it is not associated with a value
Root cause
In pdd/update_main.py, line 75 defines context_config inside the else branch (when --output is NOT provided). But line 91 uses context_config.get("generate_output_path", "") unconditionally — including when --output IS provided, causing a NameError.
# Line 70-80
if output_dir:
base_prompts_dir = os.path.abspath(output_dir) # context_config never set
else:
context_name, context_config = detect_context_for_file(...) # only defined here
# Line 91 — reached regardless
code_root = context_config.get("generate_output_path", "") # NameError if --output was used
Only triggers when the code file is in a subdirectory (so rel_dir != "." at line 85).
Suggested fix
Default context_config = {} before the if/else branch so .get() returns the fallback value.
Description
pdd update <code_file> --output <path>crashes withNameErrorwhen the code file is in a subdirectory.Reproduction
Actual output
Root cause
In
pdd/update_main.py, line 75 definescontext_configinside theelsebranch (when--outputis NOT provided). But line 91 usescontext_config.get("generate_output_path", "")unconditionally — including when--outputIS provided, causing aNameError.Only triggers when the code file is in a subdirectory (so
rel_dir != "."at line 85).Suggested fix
Default
context_config = {}before theif/elsebranch so.get()returns the fallback value.