Merge pull request #406 from mcdonc/fix/permissionerror-permanent

fix: classify PermissionError as PermanentError
This commit is contained in:
Yiorgis Gozadinos 2026-06-01 15:49:47 +03:00 committed by GitHub
commit bf45c4efa8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -60,6 +60,9 @@ def _classify(exc: BaseException) -> Exception:
if isinstance(exc, FileNotFoundError):
return PermanentError(f"file not found: {exc}")
if isinstance(exc, PermissionError):
return PermanentError(f"permission denied: {exc}")
if isinstance(exc, asyncio.TimeoutError | TimeoutError | OSError):
return TransientError(f"timeout/io: {exc}")

View file

@ -270,3 +270,12 @@ async def test_file_not_found_classified_as_permanent():
client.create_document_from_source.side_effect = FileNotFoundError("gone")
with pytest.raises(PermanentError, match="file not found"):
await run_job(client, _job())
@pytest.mark.asyncio
async def test_permission_error_classified_as_permanent():
"""An unreadable file should go straight to the DLQ, not retry."""
client = _mock_client()
client.create_document_from_source.side_effect = PermissionError("no access")
with pytest.raises(PermanentError, match="permission denied"):
await run_job(client, _job())