Merge pull request #400 from mcdonc/fix/filenotfound-permanent-error
fix: classify FileNotFoundError as PermanentError
This commit is contained in:
commit
4372b0546d
2 changed files with 12 additions and 0 deletions
|
|
@ -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}")
|
||||
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Reference in a new issue