Hey Prefect, we're getting an error related to `on...
# prefect-community
t
Hey Prefect, we're getting an error related to
on_failure
and
on_completion
. We're not sure why this is happening. We're using prefect 2.10.21 and python 3.10.11.
Copy code
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 1903, in report_flow_run_crashes
    yield
  File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 520, in begin_flow_run
    terminal_or_paused_state = await orchestrate_flow_run(
  File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 899, in orchestrate_flow_run
    await _run_flow_hooks(flow=flow, flow_run=flow_run, state=state)
  File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 2351, in _run_flow_hooks
    if state.is_failed() and flow.on_failure:
AttributeError: 'Flow' object has no attribute 'on_failure'

During handling of the above exception, another exception occurred:
it seems like we can do something like
@flow(on_completion=None, on_failure=None)
but that just doesn't feel right
d
Also having issues with
on_failure
in 2.10.21.
Copy code
Encountered exception during execution:
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/prefect/flows.py", line 167, in __init__
    hooks = list(hooks)
            ^^^^^^^^^^^
TypeError: 'function' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/prefect/engine.py", line 833, in orchestrate_flow_run
    result = await flow_call.aresult()
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 292, in aresult
    return await asyncio.wrap_future(self.future)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 316, in _run_sync
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/prefect/instagram/profiles/flows.py", line 69, in instagram_profile_master_etl
    instagram_profile_client_etl.with_options(
  File "/usr/local/lib/python3.11/site-packages/prefect/flows.py", line 364, in with_options
    return Flow(
           ^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/context.py", line 179, in __register_init__
    __init__(__self__, *args, **kwargs)
  File "/usr/local/lib/python3.11/site-packages/prefect/flows.py", line 169, in __init__
    raise TypeError(
TypeError: Expected iterable for 'on_failure'; got function instead. Please provide a list of hooks to 'on_failure':

@flow(on_failure=[hook1, hook2])
def my_flow():
	pass
05:03:49 PM
prefect.flow_runs
Finished in state Failed("Flow run encountered an exception. TypeError: Expected iterable for 'on_failure'; got function instead. Please provide a list of hooks to 'on_failure':\n\n@flow(on_failure=[hook1, hook2])\ndef my_flow():\n\tpass")
We aren't using hooks here, not sure what's triggering this.
Downgraded to 2.10.19 and we're running normally again.