<#3437 fix(iterator): raise TypeTransformerFailedE...
# flyte-github
a
#3437 fix(iterator): raise TypeTransformerFailedError with a message to prevent IndexError in callers Pull request opened by devteamaegis What's broken When IteratorTransformer.to_python_value receives a non-collection literal (e.g. a scalar), it catches the AttributeError from lv.collection.literals and re-raises TypeTransformerFailedError() with no arguments (args = ()). Multiple callers in promise.py (lines 103, 1235, 1360), base_task.py (line 312), and base_connector.py (line 350) then do exc.args = (f"...{exc.args[0]}...",) to enrich the error message. Because exc.args is an empty tuple, accessing exc.args[0] raises IndexError: tuple index out of range, which swallows the original type conversion failure entirely. Why it happens TypeTransformerFailedError() was raised with no arguments, leaving args as an empty tuple, which callers throughout the codebase assume is non-empty. Fix Replace the bare except/re-raise with an explicit None-check on lv.collection and pass a descriptive message string to TypeTransformerFailedError, so exc.args[0] is always valid for callers to safely index. Test Added test_to_python_value_non_collection_raises_with_message in tests/flytekit/unit/types/iterator/test_iterator.py that passes a scalar literal to to_python_value and asserts the raised TypeTransformerFailedError has a non-empty args tuple. flyteorg/flytekit