It is indeed a corner case, we have tasks in our workflows that return a FlyteDirectory, which can be empty - an example would be a task that creates visualizations of bounding boxes from a previous object detection stage - if there are no bounding boxes, this FlyteDirectory would be empty. Optional is the way we handle things currently, but it would make things a bit cleaner, if FlyteDirectory could handle this internally (e.g. returning a path to an empty folder when calling .download(). If this is just a missed corner case, great - then I will add it to the list of potential UX improvements (
https://github.com/flyteorg/flyte/issues/4542). After reading this discussion, I had the impression, this design was on purpose:
https://github.com/flyteorg/flyte/discussions/3502#discussioncomment-5617773