# ask-the-community

Jay Ganbat

06/28/2023, 6:08 PM
Hi flyte folks, i think i encountered another Optional type related issue. This seem to be happening only during local execution though. Issue: For dynamic tasks with Optional return it crashes if we explicitly return None. Example code:
Copy code
def dyn_optional_str(optional_str: Optional[str]) -> Optional[str]:
    return None

def workflow_with_optional_input(optional_str: Optional[str]) -> Optional[str]:
    hello_output = dyn_optional_str(optional_str=optional_str)
    return hello_output
and test was done like this
Copy code
def test_example() -> None:
    result = workflow_with_optional_input(optional_str=None)
    assert result is None
and it crashes with this error
Copy code
except Exception as e:
                    logger.error(f"Failed to convert return value for var {k} with error {type(e)}: {e}")
>                   raise TypeError(
                        f"Failed to convert return value for var {k} for function {} with error {type(e)}: {e}"
                    ) from e
E                   TypeError: Failed to convert return value for var o0 for function sandbox.dynamic_optional_type.dyn_optional_str with error <class 'AssertionError'>: Task sandbox.dynamic_optional_type.dyn_optional_str returns nothing, NoneType return cannot be used

/fn/lib/venv/lib/python3.10/site-packages/flytekit/core/ TypeError
i think it might be some oversight on flytekit side 🤔
if confirmed i can open up an issue ticket btw flytekit version is
maybe its fixed in later versions 🤔

Eduardo Apolinario (eapolinario)

06/28/2023, 6:45 PM
@Jay Ganbat, thanks for the report. Can you file a gh issue? I can confirm that this affects latest (1.7.0) flytekit as well.

Jay Ganbat

06/28/2023, 6:51 PM
thanks for confirming here is the issue