Merge pull request #408 from mcdonc/fix/directory-errors-permanent

fix: classify IsADirectoryError and NotADirectoryError as PermanentError
This commit is contained in:
Yiorgis Gozadinos 2026-06-01 18:07:24 +03:00 committed by GitHub
commit c0faf5ecf3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View file

@ -63,6 +63,9 @@ def _classify(exc: BaseException) -> Exception:
if isinstance(exc, PermissionError):
return PermanentError(f"permission denied: {exc}")
if isinstance(exc, IsADirectoryError | NotADirectoryError):
return PermanentError(f"path error: {exc}")
if isinstance(exc, asyncio.TimeoutError | TimeoutError | OSError):
return TransientError(f"timeout/io: {exc}")

View file

@ -279,3 +279,13 @@ async def test_permission_error_classified_as_permanent():
client.create_document_from_source.side_effect = PermissionError("no access")
with pytest.raises(PermanentError, match="permission denied"):
await run_job(client, _job())
@pytest.mark.asyncio
@pytest.mark.parametrize("exc_class", [IsADirectoryError, NotADirectoryError])
async def test_directory_errors_classified_as_permanent(exc_class):
"""Pointing at a directory instead of a file should DLQ immediately."""
client = _mock_client()
client.create_document_from_source.side_effect = exc_class("not a file")
with pytest.raises(PermanentError, match="path error"):
await run_job(client, _job())