CLI can silently replace an input document with its own export

Open
#5,567 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@basilk15 is already working on this.

Since Nov 25, 2026.

  • #5568 by @basilk15 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
cli

Research direction

Start by reproducing the overwrite with the printf/docling convert notes.md sequence from the issue on a disposable file. Then read the CLI convert entry point and the code that resolves the default output directory, looking for where it decides the destination filename before writing. The fix should detect that the destination equals an input and report the conflict before any write; add a regression test covering both the single-file and batch cases described. Note that an open pull request (#5568) already targets this, so check it before starting.

Written by the indexing model from the issue text.

Description

bug priority:critical

Running docling convert notes.md in the directory that contains notes.md can silently replace the original file. The default export is Markdown and the default output directory is the working directory.

I reproduced this with a disposable file on 22b80a43 using Python 3.12. In an empty directory, run

printf '# Notes\n\n<!-- author comment -->\n\nBody.\n' > notes.md
docling convert notes.md
cat notes.md

The command exits 0. The author comment and the final newline are gone. A directory batch can also replace a different input. For example, exporting notes.csv as text into a directory that also supplies notes.txt replaces that document with the CSV export.

The CLI should report the conflicting destination before writing to an input. A separate output directory works today. Issue #3811 tracks a different case in which two generated outputs share a name.

Dominant language
Python
Stars
71k
Forks
5.4k
Avg merge
2d 22h
Merged PRs (30d)
161

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from docling-project/docling

All issues in docling-project/docling

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.