Merge pull request #400 from mcdonc/fix/filenotfound-permanent-error

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

View file

@ -57,6 +57,9 @@ def _classify(exc: BaseException) -> Exception:
# ProxyError — every transport-layer failure that's worth retrying.
return TransientError(f"network: {exc}")
if isinstance(exc, FileNotFoundError):
return PermanentError(f"file not found: {exc}")
if isinstance(exc, asyncio.TimeoutError | TimeoutError | OSError):
return TransientError(f"timeout/io: {exc}")

View file

@ -261,3 +261,12 @@ async def test_existing_permanent_error_passes_through_unchanged():
with pytest.raises(PermanentError) as excinfo:
await run_job(client, _job())
assert excinfo.value is sentinel
@pytest.mark.asyncio
async def test_file_not_found_classified_as_permanent():
"""A deleted file should go straight to the DLQ, not retry."""
client = _mock_client()
client.create_document_from_source.side_effect = FileNotFoundError("gone")
with pytest.raises(PermanentError, match="file not found"):
await run_job(client, _job())