Hi all - we are working on implementing a solution...
# prefect-community
i
Hi all - we are working on implementing a solution to send a Slack notification on flow failures with prefect 2.0. It seems like one way to do this is to capture the flow state via the following:
Copy code
@flow(name="always-fail")
def entrypoint():
    raise ValueError("my error message")

if __name__ == "__main__":
    state = entrypoint(return_state=True)
    print(state)
    print(state.result)
In this scenario,
state.result
can give us the detailed error message for passing back into Slack which seems really useful. However, it’d also be great if we can also provide a direct link to the flow using the flow’s run id. How are other folks implementing this, and is there a way to directly access the flow’s run id after calling the flow from main (or otherwise)?
1
z
The flow run id is available at
state.state_details.flow_run_id
i
Perfect, thank you Michael!
Michael - while I have your attention, we are hoping to just use Prefect Cloud’s notification feature (https://docs.prefect.io/ui/notifications/) to accomplish this but unfortunately it’s lacking for this task since it does not pass an error message, or the flow run’s URL. I notice there is an open feature request here (https://github.com/PrefectHQ/prefect/issues/6424) which is similar but I’m not sure covers the functionality that we’re hoping for. Should I file a new feature request for this, or add a comment to this existing one?
z
A separate issue seems reasonable, just link to that one and explain how it’s different
i
Will do, thanks again.