Skip to content

fix: catch PermissionError on Windows when input is a directory#3151

Closed
zlplzp123wyt wants to merge 4 commits intodocling-project:mainfrom
zlplzp123wyt:fix/windows-permission-error
Closed

fix: catch PermissionError on Windows when input is a directory#3151
zlplzp123wyt wants to merge 4 commits intodocling-project:mainfrom
zlplzp123wyt:fix/windows-permission-error

Conversation

@zlplzp123wyt
Copy link

Fixes #3138

Problem

On Windows, pathlib.Path.read_bytes() called on a directory raises PermissionError (Errno 13) instead of IsADirectoryError (Errno 21) which is raised on Linux/macOS.

The CLI handler at docling/cli/main.py:657 only catches IsADirectoryError, so the PermissionError propagates as an unhandled exception when passing a directory as source on Windows.

Fix

Changed except IsADirectoryError: to except (IsADirectoryError, PermissionError): to handle both exceptions across platforms.

This is a minimal, safe fix — the handler logic remains unchanged, we just accept both exception types that indicate "this is a directory".

On Windows, pathlib.Path.read_bytes() called on a directory raises
PermissionError (Errno 13) instead of IsADirectoryError (Errno 21)
which is raised on Linux/macOS. This caused the CLI to crash when
passing a directory as source on Windows.

Fixes docling-project#3138
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

DCO Check Passed

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

@mergify
Copy link

mergify bot commented Mar 18, 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)(?:\(.+\))?(!)?:

Signed-off-by: zlplzp123wyt <zlplzp123wyt@users.noreply.github.com>
…ithub.com>

I, zlplzp123wyt <zlplzp123wyt@users.noreply.github.com>, hereby add my Signed-off-by to this commit to resolve the DCO check failure on PR docling-project#3151.

Signed-off-by: zlplzp123wyt <zlplzp123wyt@users.noreply.github.com>
…ithub.com>

I, zlplzp123wyt <zlplzp123wyt@users.noreply.github.com>, hereby add my Signed-off-by to this commit: 717dcdf

Signed-off-by: zlplzp123wyt <zlplzp123wyt@users.noreply.github.com>
@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
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

2 participants