PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
15.36k stars 1.51k forks source link

Flow returning None with failed task ends with state Completed instead of Failed #14470

Open GalLadislav opened 6 days ago

GalLadislav commented 6 days ago

First check

Bug summary

Flow returning None with failed task ends with state Completed instead of Failed. This issue happens for documented example code for Return None.

This behavior occurs for tasks too.

Reproduction

import prefect

@prefect.task()
def task1():
    raise ValueError("Task 1 failed")

@prefect.task()
def task2():
    task1.submit().result(raise_on_failure=False)

@prefect.flow()
def flow_failed_submit():
    task1.submit().result(raise_on_failure=False)
    task2.submit().result(raise_on_failure=False)

@prefect.flow()
def flow_failed_state():
    task1(return_state=True)
    task2(return_state=True)

if __name__ == "__main__":
    flow_failed_submit(return_state=True)
    flow_failed_state(return_state=True)

Error

No response

Versions (prefect version output)

Version:             3.0.0rc9
API version:         0.8.4
Python version:      3.12.4
Git commit:          b75631a7
Built:               Mon, Jun 24, 2024 5:50 PM
OS/Arch:             linux/x86_64
Profile:             default
Server type:         ephemeral
Pydantic version:    2.8.0
Server:
  Database:          sqlite
  SQLite version:    3.37.2

Additional context

prefect.flow_engine.FlowRunEngine.handle_success() should probably in case of returned None value pass to prefect.states.return_value_to_state() list of task run results from RunContext?

zhen0 commented 6 days ago

Thanks for the issue @GalLadislav - we'll look into this one.