docling-project / docling-project/docling
CLI silently overwrites outputs for inputs with the same file stem
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
### Bug
When one `docling convert` invocation receives files from different directories that share the same stem, every result is exported to the same flat output path. Each later document silently overwrites the earlier document and the CLI still exits with status 0.
The problem affects all formats produced by `export_documents()` because each filename is derived only from `conv_res.input.file.stem`. It is particularly damaging for the new `chunks` output used in RAG ingestion: a successful batch can silently contain chunks for only the last same-named source.
On the current `main` commit `e548307e8d32bb197c787b1f2998a87bafbc743b`, converting the two repository README files together produced only one `README.chunks.jsonl`:
```text
exit_code=0
README.chunks.jsonl: 57 lines
SHA256: 88C8F484ADACACB9EEA65A902B0DADEA1E7252E0541D99E605294369E318B74B
```
Converting the inputs separately confirms that they produce different data:
```text
README.md: 28 chunks
SHA256: 4A5023BE2E2899B7ADF309756863DCE0B31DA26EF734EA0197298BC0F5ADB417
packages/docling-slim/README.md: 57 chunks
SHA256: 88C8F484ADACACB9EEA65A902B0DADEA1E7252E0541D99E605294369E318B74B
```
The combined output hash exactly matches the second input, so the first 28 chunks were overwritten.
Expected behavior: one invocation must not silently discard successful conversions. Colliding output stems should either receive deterministic unique names while preserving input order, or the CLI should fail clearly before overwriting data.
I searched open and closed issues and pull requests for same-filename output overwrites, basename/stem collisions, and `chunks.jsonl` collisions. I also checked the open PRs touching CLI export code and the chunks export PR #3732; I did not find an existing report or fix.
### Steps to reproduce
From the repository root:
```console
uv sync --extra standard
uv run docling convert README.md packages/docling-slim/README.md \
--from md \
--to chunks \
--chunks-type hierarchical \
--output out
```
Then inspect the output:
```console
ls out
wc -l out/README.chunks.jsonl
```
Actual result: only `README.chunks.jsonl` exists and contains the second document's 57 chunks. The command exits successfully.
The same collision can be observed with regular document exports, for example by adding `--to md`: only one `README.md` is retained.
### Docling version
```text
Docling version: 2.113.0
Docling Core version: 2.86.0
Docling IBM Models version: 3.13.3
Docling Parse version: 7.7.0
main commit: e548307e8d32bb197c787b1f2998a87bafbc743b
```
### Python version
```text
Python 3.13.12
Windows 11 10.0.26200
```
Contributor guide
Research direction
Start at the CLI export path and the export_documents() filename construction described in the issue, then run the provided uv run docling convert command with the two README inputs. Trace how each output path is selected across formats and add a regression test covering same-stem inputs; done means the batch no longer silently loses a successful conversion and the command’s behavior is covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100