BUG: IndexError in IODescriptor.from_output() with bare (unparameterized) iterator return annotations
Author: devteamaegisCreated Jun 1, 2026Updated Sep 13, 2026
What breaks
IODescriptor.from_output() crashes with an IndexError when a service method's return annotation is an unparameterized iterator type such as t.Iterator, t.Generator, t.AsyncIterator, or t.AsyncGenerator (and their collections.abc equivalents).
How to trigger
import typing as t
from _bentoml_sdk.io_models import IODescriptor
def my_stream_fn() -> t.Iterator:
yield 1
IODescriptor.from_output(my_stream_fn) # raises IndexErrorTraceback
File "src/_bentoml_sdk/io_models.py", line 435, in from_output
return_annotation = get_args(return_annotation)[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: tuple index out of rangeRoot cause
is_iterator_type() correctly returns True for bare generics, but get_args() returns an empty tuple () for unparameterized types. Line 435 unconditionally indexes position 0 without checking the length first. The surrounding try/except on lines 447–450 only catches ValueError and TypeError, so the IndexError escapes and crashes service startup.
Source: bentoml/BentoML