<#1882 Improve error message in ListTransformer wh...
# flyte-github
a
#1882 Improve error message in ListTransformer when not passing a list Pull request opened by fg91 TL;DR Improve error message in
ListTransformer
in a way that would have saved us time debugging a failing workflow. Type Neither of the following, just adding a meaningful error message. ☐ Bug Fix ☐ Feature ☐ Plugin Are all requirements met? ☑︎ Code completed ☑︎ Smoke tested ☐ Unit tests added ☐ Code documentation added ☑︎ Any pending items have an associated Issue Complete description This workflow ...
Copy code
from flytekit import task, workflow

@task
def foo() -> int:
    return 1

@task
def bar(inp: list[int]):
    print(inp)

@workflow
def wf():
    bar(inp=foo())


if __name__ == "__main__":
    wf()
... fails with:
Copy code
Traceback (most recent call last):
  File ".../test.py", line 17, in <module>
    wf()
  File ".../flytekit/flytekit/core/workflow.py", line 279, in __call__
    raise exc
  File ".../flytekit/flytekit/core/workflow.py", line 276, in __call__
    return flyte_entity_call_handler(self, *args, **input_kwargs)
  File ".../flytekit/flytekit/core/promise.py", line 1051, in flyte_entity_call_handler
    result = cast(LocallyExecutable, entity).local_execute(child_ctx, **kwargs)
  File ".../flytekit/flytekit/core/workflow.py", line 298, in local_execute
    function_outputs = self.execute(**kwargs_literals)
  File ".../flytekit/flytekit/core/workflow.py", line 746, in execute
    return exception_scopes.user_entry_point(self._workflow_function)(**kwargs)
  File ".../flytekit/flytekit/exceptions/scopes.py", line 203, in user_entry_point
    raise type(exc)(f"Error encountered while executing '{fn_name}':\n  {exc}") from exc
flytekit.core.type_engine.TypeTransformerFailedError: Encountered error while executing workflow 'wf':
  Error encountered while executing 'wf':
  Failed to convert inputs of task 'test.bar':
  Error converting input 'inp' at position 0:  # <- No meaningful error comes after this colon
In this minimal example, the error is quickly apparent but one of our engineers struggled to find the issue in a large training workflow. A hint that a list/collection is expected but not provided (as here in the respective
to_literal
method) would have greatly simplified the search:
Copy code
flytekit.core.type_engine.TypeTransformerFailedError: Encountered error while executing workflow 'wf':
  Error encountered while executing 'wf':
  Failed to convert inputs of task 'test.bar':
  Error converting input 'inp' at position 0:
  The expected python type is 'list[int]' but the received Flyte literal value is not a collection (Flyte's representation of Python lists).
Tracking Issue NA Follow-up issue NA flyteorg/flytekit ✅ All checks have passed 30/30 successful checks