<#6426 [BUG] Conditionals do not work correctly wi...
# flyte-github
c
#6426 [BUG] Conditionals do not work correctly with nested workflows Issue created by abhay-vardhan-ai ### Describe the bug Consider the following code:
Copy code
from flytekit import task, workflow, conditional

@workflow
def sub_workflow() -> bool:
    some_test = do_test()
    (
        conditional("maybe_do_nothing")
        .if_(some_test.is_true())
        .then(do_nothing1())
        .else_()
        .then(do_nothing2())
    )
    return True

@workflow
def top_workflow(
    input_value: bool = False,
) -> None:
    (
        conditional("maybe_workflow")
        .if_(input_value.is_true())
        .then(sub_workflow())
        .else_()
        .then(do_nothing3())
    )

@task
def do_nothing1() -> bool:
    print("do_nothing1")
    return True

@task
def do_nothing2() -> bool:
    print("do_nothing2")
    return True

@task
def do_nothing3() -> bool:
    print("do_nothing3")
    return True

@task
def do_test() -> bool:
    print("do_test")
    return False

top_workflow(input_value=True)
I have top_workflow which calls a sub_workflow based on a condition. The sub_workflow does another conditional. But I see that it is executing both branches in the sub_workflow
Copy code
do_test
do_nothing1
do_nothing2
### Expected behavior The sub_workflow contitional should only execute on the branch that evaluates to true In the example above the expected output is
Copy code
do_test
do_nothing1
### 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