Skip to content

fix: evaluate indexed values in local conditionals - #3468

Open
1fanwang wants to merge 3 commits into
flyteorg:masterfrom
1fanwang:1fannnw/fix-indexed-none-conditional
Open

1fanwang wants to merge 3 commits into
flyteorg:masterfrom
1fanwang:1fannnw/fix-indexed-none-conditional

Conversation

@1fanwang

@1fanwang 1fanwang commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Tracking issue

Related to flyteorg/flyte#6473.

Why are the changes needed?

A local workflow cannot check whether an indexed list entry is None. It raises an error instead of selecting a branch:

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

What changes were proposed in this pull request?

When a local workflow compares an indexed value, such as the first item in a task's list output, the comparison now looks that item up before checking it. The lookup runs on a copy, so other uses of the same output keep their original value. A workflow that is only being compiled has no values yet, so its references to indexed items are left as written.

How was this patch tested?

Testing Done

The same local CLI path now selects the expected branch without a remote Flyte cluster.

Scenario Command Result
Indexed optional entry pyflyte run indexed_none_repro.py wf Task succeeded
Reproducer source: indexed_none_repro.py
from flytekit import conditional, task, workflow
from flytekit.core.task import Echo

echo: Echo = Echo(name="branch_result", inputs={"value": str})


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


@workflow
def wf() -> str:
    status = check_status()[0]
    return (
        conditional("status_check")
        .if_(status.is_none())
        .then(echo(value="Task succeeded"))
        .else_()
        .then(echo(value="Task failed"))
    )
pyflyte run indexed_none_repro.py wf
Running Execution on local.
Task succeeded
exit_code=0

The original failing comparison used d69b3fb:

Running Execution on local.
AttributeError: 'NoneType' object has no attribute 'union'
exit_code=1

Setup process

Python 3.12 with the SDK development environment and this checkout on PYTHONPATH.

Screenshots

Not applicable.

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

The documented API is unchanged.

Related PRs

None.

Docs link

No separate documentation change.

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant