Skip to content

Duplicated normalize_file_path in Export Script #46

@bradjin8

Description

@bradjin8

Repository: cppa-cursor-browser
Assignee: Brad @bradjin8
Severity: Medium

Problem

The normalize_file_path function exists in two independent copies: one in utils/path_helpers.py (used by the web app) and one inside scripts/export.py (used by CLI export). Both copies contain Windows-specific logic — backslash normalization, drive-letter lowercasing, file:/// URI handling — but they are maintained independently. A bug fix or enhancement to one copy does not propagate to the other. Since neither copy is exercised on actual Windows in CI (see item 3), divergence between the two implementations is undetectable until a user reports broken behavior on one code path but not the other.

Acceptance Criteria

  • Only one normalize_file_path implementation exists in the codebase (in utils/path_helpers.py)
  • scripts/export.py imports normalize_file_path from utils/path_helpers.py instead of defining its own copy
  • All tests that previously covered the export script's private copy are migrated to test the shared implementation
  • A dedicated test module (or test cases within an existing module) exercises normalize_file_path with Windows-style paths, file:/// URIs, percent-encoded characters, and edge cases (spaces, # in paths)
  • No other duplicated utility functions remain in scripts/export.py (audit for to_epoch_ms and similar)

Implementation Notes

This item is a prerequisite cleanup that naturally feeds into item 1 (full export script refactoring) and depends on item 4 (pyproject.toml) for clean imports. If item 4 is not yet landed, the sys.path.insert hack can temporarily enable the import, but the cleaner sequencing is: item 4 → item 5 → item 1. When deduplicating, compare the two implementations line-by-line to ensure neither has a bug fix the other lacks — merge the best of both into the canonical utils/path_helpers.py version.

References

  • Eval finding: test 4
  • Cluster: path-normalization-duplication
  • Related files: utils/path_helpers.py, scripts/export.py (search for def normalize_file_path)
  • Compounds: COMPOUND-A (parallel impl blocks utility consolidation), COMPOUND-D (path duplication + single-OS CI)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions