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 IndexError
Traceback
File "src/_bentoml_sdk/io_models.py", line 435, in from_output
return_annotation = get_args(return_annotation)[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: tuple index out of range
Root 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.
What breaks
IODescriptor.from_output()crashes with anIndexErrorwhen a service method's return annotation is an unparameterized iterator type such ast.Iterator,t.Generator,t.AsyncIterator, ort.AsyncGenerator(and theircollections.abcequivalents).How to trigger
Traceback
Root cause
is_iterator_type()correctly returnsTruefor bare generics, butget_args()returns an empty tuple()for unparameterized types. Line 435 unconditionally indexes position 0 without checking the length first. The surroundingtry/excepton lines 447–450 only catchesValueErrorandTypeError, so theIndexErrorescapes and crashes service startup.