Alastair
02/23/2026, 8:08 PMclient.set_flow_run_state?Marvin
02/23/2026, 8:08 PMMarvin
02/23/2026, 8:11 PMmessage field. When you call client.set_flow_run_state, pass a state that includes message.
Examples:
- Async (Prefect 3.x default client)
from prefect.client.orchestration import PrefectClient
from prefect.states import Completed, Failed
async with PrefectClient() as client:
await client.set_flow_run_state(
flow_run_id,
state=Completed(message="Manually completed for testing")
)
await client.set_flow_run_state(
flow_run_id,
state=Failed(message="Upstream dataset missing"),
force=True, # if you need to override
)
- Constructing a State explicitly
from prefect.client.schemas.objects import State, StateType
await client.set_flow_run_state(
flow_run_id,
State(type=StateType.COMPLETED, message="Replayed with cached results")
)
That message will show up in the UI as the “Reason.”