-
Notifications
You must be signed in to change notification settings - Fork 53
Closed
Description
Bug Description
The operation_log.py module does not sanitize basenames containing slashes (/), while sync_determine_operation.py and sync_orchestration.py do. This causes state desynchronization and crashes when using subdirectory basenames like pdd sync core/cloud.
What Breaks:
- CLI mode crashes with
FileNotFoundErrorwhen trying to save fingerprints - TUI vs CLI inconsistency - same command behaves differently
- State desynchronization - reader and writer use different file paths
- Workflow loses track of completed operations
Root Cause
Reader (sync_determine_operation.py:786):
fingerprint_file = meta_dir / f"{_safe_basename(basename)}_{language}.json"
# For "core/cloud" → .pdd/meta/core_cloud_python.json ✓Writer TUI mode (sync_orchestration.py:217):
fingerprint_file = META_DIR / f"{_safe_basename(basename)}_{language}.json"
# For "core/cloud" → .pdd/meta/core_cloud_python.json ✓ SAMEWriter CLI mode (operation_log.py:228):
path = get_fingerprint_path(basename, language)
# Returns: Path(META_DIR) / f"{basename}_{language}.json" # ⚠️ No sanitization!
# For "core/cloud" → .pdd/meta/core/cloud_python.json ✗ DIFFERENTSteps to Reproduce
# 1. Create a prompt with subdirectory basename
mkdir -p prompts/core
cat > prompts/core/cloud_python.prompt << 'END'
Write a simple hello world function
END
# 2. Run sync in CLI mode (not TUI)
pdd sync core/cloud
# 3. Observe the crash:
# FileNotFoundError: [Errno 2] No such file or directory:
# '.pdd/meta/core/cloud_python.json'Expected Behavior
All code paths should use the same sanitized basename:
.pdd/meta/core_cloud_python.json.pdd/meta/core_cloud_python_run.json.pdd/meta/core_cloud_python_sync.log.pdd/locks/core_cloud_python.lock
Actual Behavior
CLI mode tries to write to unsanitized paths:
.pdd/meta/core/cloud_python.json← Tries to create subdirectory, crashes.pdd/meta/core/cloud_python_run.json← Different from reader.pdd/meta/core/cloud_python_sync.log← Different from reader
Files Affected
pdd/operation_log.py:25-40- Missing sanitization in:get_log_path()get_fingerprint_path()get_run_report_path()
Proposed Fix
Add basename sanitization to operation_log.py:
def get_log_path(basename: str, language: str) -> Path:
"""Get the path to the sync log for a specific module."""
ensure_meta_dir()
safe_basename = basename.replace('/', '_') # Add sanitization
return Path(META_DIR) / f"{safe_basename}_{language}_sync.log"
def get_fingerprint_path(basename: str, language: str) -> Path:
"""Get the path to the fingerprint JSON file for a specific module."""
ensure_meta_dir()
safe_basename = basename.replace('/', '_') # Add sanitization
return Path(META_DIR) / f"{safe_basename}_{language}.json"
def get_run_report_path(basename: str, language: str) -> Path:
"""Get the path to the run report file for a specific module."""
ensure_meta_dir()
safe_basename = basename.replace('/', '_') # Add sanitization
return Path(META_DIR) / f"{safe_basename}_{language}_run.json"Or import the existing _safe_basename() from sync_determine_operation.py.
Additional Context
The _safe_basename() function already exists in sync_determine_operation.py:71 specifically to handle this case, but operation_log.py doesn't use it. This oversight causes TUI mode to work (which uses sanitized paths) while CLI mode crashes.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels