Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/on_failure/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def step1(self, context: Context) -> None:
def on_failure(self, context: Context) -> dict[str, str]:
# 👀 we can do things like perform cleanup logic
# or notify a user here

# 👀 Fetch the errors from upstream step runs from the context
print(context.step_run_errors())

return {"status": "success"}


Expand Down
10 changes: 10 additions & 0 deletions hatchet_sdk/context/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,16 @@ def child_key(self) -> str | None:
def parent_workflow_run_id(self) -> str | None:
return self.action.parent_workflow_run_id

def step_run_errors(self) -> dict[str, str]:
errors = cast(dict[str, str], self.data.get("step_run_errors", {}))

if not errors:
logger.error(
"No step run errors found. `context.step_run_errors` is intended to be run in an on-failure step, and will only work on engine versions more recent than v0.53.10"
)

return errors

def fetch_run_failures(self) -> list[dict[str, StrictStr]]:
data = self.rest_client.workflow_run_get(self.action.workflow_run_id)
other_job_runs = [
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hatchet-sdk"
version = "0.43.3"
version = "0.44.0"
description = ""
authors = ["Alexander Belanger <alexander@hatchet.run>"]
readme = "README.md"
Expand Down
Loading