Skip to content

fix: handle PermissionError for directory input on Windows CLI#3149

Merged
ceberam merged 2 commits intodocling-project:mainfrom
joaquinhuigomez:fix/windows-cli-permissionerror
Mar 19, 2026
Merged

fix: handle PermissionError for directory input on Windows CLI#3149
ceberam merged 2 commits intodocling-project:mainfrom
joaquinhuigomez:fix/windows-cli-permissionerror

Conversation

@joaquinhuigomez
Copy link
Contributor

@joaquinhuigomez joaquinhuigomez commented Mar 17, 2026

Summary

Fixes #3138

On Windows, Path.read_bytes() raises PermissionError when called on a directory path, while Unix raises IsADirectoryError. This causes the CLI to crash when processing directory inputs on Windows.

Fix: Add PermissionError to the existing except IsADirectoryError clause in docling/cli/main.py:657. The subsequent local_path.is_dir() check on line 661 already validates the path is actually a directory, so a genuine file permission error would not pass that guard.

Test plan

  • Verified the is_dir() guard on line 661 prevents false positives from real permission errors
  • Test on Windows with directory input

On Windows, Path.read_bytes() on a directory raises PermissionError
instead of IsADirectoryError (which is raised on Linux/macOS). This
caused the CLI to crash when a directory was passed as input source.

Catch PermissionError alongside IsADirectoryError so directory inputs
are handled correctly on all platforms.

Fixes docling-project#3138

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

DCO Check Passed

Thanks @joaquinhuigomez, all your commits are properly signed off. 🎉

@mergify
Copy link

mergify bot commented Mar 17, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

I, Joaquin Hui Gomez <joaquinhui1995@gmail.com>, hereby add my Signed-off-by to this commit: 90c738c

Signed-off-by: Joaquin Hui Gomez <joaquinhui1995@gmail.com>
Copy link
Member

@PeterStaar-IBM PeterStaar-IBM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@PeterStaar-IBM
Copy link
Member

I see duplicate PR (#3145)

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
docling/cli/main.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ceberam
Copy link
Member

ceberam commented Mar 18, 2026

Duplicate of #3140

@ceberam ceberam marked this as a duplicate of #3140 Mar 18, 2026
@ceberam ceberam closed this Mar 18, 2026
@ceberam ceberam reopened this Mar 19, 2026
@ceberam ceberam merged commit a39317a into docling-project:main Mar 19, 2026
46 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: directory input crashes with PermissionError on Windows

4 participants