Skip to content

Markdown export silently overwrites when two sources differ only by extension #32

Description

@charitarthchugh

get_markdown_path() in src/paperscale/pipeline.py:691 builds the output filename with:

md_filename = os.path.splitext(os.path.basename(relative_path))[0] + ".md"

It drops the source extension. paperscale accepts both PDFs and images (--pdfs takes
"Local PDF/image paths, a local glob ... or a .txt file listing paths"), so two source files
in one directory that differ only by extension collide onto a single markdown file:

corpus/case.pdf   ->  workspace/markdown/corpus/case.md
corpus/case.tiff  ->  workspace/markdown/corpus/case.md   # overwrites, silently

Whichever document is exported second wins. Nothing warns, and the loss is invisible unless
you count the output files against the input list.

Related precedent: evaluation/runs.py:45 already treats a duplicate Source-File inside one
run as fatal (DuplicateSourceFileError) on exactly the grounds that an ambiguous document key
is not recoverable. The export path has no equivalent guard.

Found while resolving #22. That ticket chose extension-replacement for the embed output too, so
the same collision family will exist on the .npz side and both should be fixed by the same
rule — see #22's resolution, which makes the path-hash the tiebreak.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions