flyteorg / flyteorg/flyte

[BUG] is_none() does not work with list inputs as conditionals

Open
#6,473 2 comments 0 reactions 0 assignees View on GitHub
bug untriaged
Dominant language
Go
Stars
7.5k
Forks
886
Avg merge
1d 14h
Merged PRs (30d)
120

Description

### Describe the bug

`is_none()` throws an error when trying to evaluate if an indexed list item is `None` inside of a conditional.

The error below is reproducible from the code excerpt in the additional context.

```
AttributeError: 'NoneType' object has no attribute 'union'
```

This error is caused from a much more complex pipeline that is doing the same thing:
```
Error 0: Code: ValueRequired, Node Id: n1, Description: Value required [RightValue.Val].
```

### Expected behavior

Lists with `None` values should be able to be evaluated without typing or attribute issues.

### Additional context to reproduce

```
from typing import Optional, Union
from flytekit import conditional, task, workflow

@task
def check_status() -> list[Optional[bool]]:
return [None, True]

@task
def success_task() -> str:
return "Task succeeded"

@task
def failure_task() -> str:
return "Task failed"

@workflow
def wf() -> Optional[Union[str, bool]]:
status = check_status()[0]
return (
conditional("status_check")
.if_(status.is_none())
.then(success_task())
.else_()
.then(failure_task())
)

if __name__ == '__main__':
result = wf()
print(result)
```

### Screenshots

_No response_

### Are you sure this issue hasn't been raised already?

- [x] Yes

### Have you read the Code of Conduct?

- [x] Yes

Contributor guide

Open the contributing guide

Research direction

Start with the provided workflow reproduction and trace the implementation of indexed list values, is_none(), and conditional evaluation. Add a regression test covering a list containing None used as a conditional, then verify that the workflow evaluates without the AttributeError or ValueRequired error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.