Service client silently discards exceptions raised by input iterators
Bug
submit_and_retrieve_each() silently completes when the input iterable raises an exception. This affects both AsyncDoclingServiceClient and the synchronous facade on current main, 90234a71b16785d08fd2f46ec62668dd2396db76.
An unreadable input manifest can therefore look like a successfully exhausted empty batch. Errors raised while obtaining the next input are distinct from conversion errors for an input that was obtained successfully.
Reproduction
This uses the public async API and makes no HTTP requests because the manifest fails before the first input:
import asyncio
from pathlib import Path
from tempfile import TemporaryDirectory
from docling.service_client import AsyncDoclingServiceClient, ConversionItem
from docling.datamodel.service.targets import InBodyTarget
def items(manifest):
with manifest.open(encoding="utf-8") as stream:
for line in stream:
yield ConversionItem(source=line.strip())
async def main(manifest):
async with AsyncDoclingServiceClient(url="http://docling-service.invalid") as client:
outcomes = [
outcome
async for outcome in client.submit_and_retrieve_each(
items(manifest), target=InBodyTarget()
)
]
print(outcomes)
with TemporaryDirectory() as directory:
asyncio.run(main(Path(directory) / "missing-manifest.txt"))
Actual: prints [] without raising. Expected: propagate FileNotFoundError. The equivalent call to DoclingServiceClient.submit_and_retrieve_each() also returns normally. Verified locally with Python 3.13.12 and the current editable docling-slim checkout.
Cause and focused approach
In service_client/_scheduler.py, next(item_iterator) runs outside the per-item exception boundary. A failing worker only sends _WorkerDone() in finally; the consumer treats that as normal completion and the cleanup gather(..., return_exceptions=True) discards the worker exception.
I am preparing a focused fix that carries the unexpected worker failure to the consumer, which can re-raise it and clean up the other workers. Per-item conversion exceptions should continue to be returned as item outcomes. Regression coverage will use the public sync and async APIs, including an input failure after an earlier result.
Disclosure
OpenAI Codex autonomously investigated and reproduced this report under the account owner's standing authorization. No manual human review took place before this report.
Classification labels added: bug, priority:medium.
These labels are advisory. Maintainers can correct them. The workflow preserves these corrections.