<#6628 [BUG] [flytekit] Incorrect error message wh...
# flyte-github
a
#6628 [BUG] [flytekit] Incorrect error message when converting types (referring to wrong argument) Issue created by pimdh ### Flyte & Flytekit version Flytekit 1.16.3 (also seems present on master) ### Describe the bug When there's an error in type conversion, the error message always refer the last argument, even if that's not where the error is. This is caused by a bug in the following code: https://github.com/flyteorg/flytekit/blob/9effe915c0dfdd1b9870ce0539ed0aec3ccda80c/flytekit/core/type_engine.py#L1579 The variable
k
in this code will always refer to the final arg, even if that's not where the error occurred. To reproduce, run from flytekit import task, workflow from flytekit.types.directory import FlyteDirectory @task def process_directory(input_dir: FlyteDirectory, description: str) -> str: """Process a directory with a description.""" return f"Processing directory: {input_dir.path} with description: {description}" @workflow def main_workflow(input_dir: FlyteDirectory, description: str) -> str: """Main workflow that calls the task.""" return process_directory(input_dir=input_dir, description=description) if name == "__main__": # Incorrectly passing empty string as first argument (should be FlyteDirectory) result = main_workflow(input_dir=FlyteDirectory(""), description="Sample processing job") print(result) which will give the unhelpful errormessage:
Copy code
TypeTransformerFailedError: Error encountered while converting inputs of 'example_flyte_task.process_directory':
  Error converting input 'description' at position 1:
Literal value: Flyte Serialized object (Literal):
  scalar:
    primitive:
      string_value: Sample processing job
Expected Python type: <class 'str'>
Exception: USER:AssertionError: error=Expected a directory, but the given uri '' is not a directory.
### Expected behavior I'd expect an error message like the following (achieved by removing the 2nd arg):
Copy code
TypeTransformerFailedError: Error encountered while converting inputs of 'example_flyte_task.process_directory':
  Error converting input 'input_dir' at position 0:
Literal value: Flyte Serialized object (Literal):
  scalar:
    blob:
      metadata:
        type:
          dimensionality: 1
Expected Python type: <class 'flytekit.types.directory.types.FlyteDirectory'>
Exception: USER:AssertionError: error=Expected a directory, but the given uri '' is not a directory.
### Additional context to reproduce No response ### Screenshots No response ### Are you sure this issue hasn't been raised already? • Yes ### Have you read the Code of Conduct? • Yes flyteorg/flyte