Title: Add `FailureDetails.is_caused_by()` to mirror .NET's `TaskFailureDetails.IsCausedBy
Open Graph Title: Add `FailureDetails.is_caused_by()` to mirror .NET's `TaskFailureDetails.IsCausedBy
X Title: Add `FailureDetails.is_caused_by()` to mirror .NET's `TaskFailureDetails.IsCausedBy
Description: Summary The .NET SDK exposes TaskFailureDetails.IsCausedBy
Open Graph Description: Summary The .NET SDK exposes TaskFailureDetails.IsCausedBy
X Description: Summary The .NET SDK exposes TaskFailureDetails.IsCausedBy<T>() / IsCausedBy(Type), which lets a caller introspect an orchestration/activity failure and ask "was this caused by exception...
Opengraph URL: https://github.com/microsoft/durabletask-python/issues/162
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add `FailureDetails.is_caused_by()` to mirror .NET's `TaskFailureDetails.IsCausedBy\u003cT>()`","articleBody":"## Summary\n\nThe .NET SDK exposes [`TaskFailureDetails.IsCausedBy\u003cT>()` / `IsCausedBy(Type)`](https://github.com/microsoft/durabletask-dotnet/blob/main/src/Abstractions/TaskFailureDetails.cs), which lets a caller introspect an orchestration/activity failure and ask \"was this caused by exception type `T`?\" (with base-type support). The Python `FailureDetails` (`durabletask/task.py`) exposes `message`, `error_type`, and `stack_trace`, but has **no equivalent introspection helper** — callers must compare `failure_details.error_type` against a type name string by hand.\n\nThis is a general-purpose gap in the Python SDK's failure-introspection surface, not specific to any one feature.\n\n## Background / motivation\n\nThis came up during the scheduled-tasks PR (#160). The schedule client surfaces entity-side failures (e.g. an invalid state transition) as a generic `RuntimeError` carrying the failure message — which matches the current .NET ScheduledTasks client behavior (it throws a generic `InvalidOperationException` with `FailureDetails.ErrorMessage`). A more Pythonic API would let callers do something like:\n\n```python\ntry:\n schedule_client.pause()\nexcept OrchestrationError as e:\n if e.failure_details.is_caused_by(ScheduleInvalidTransitionError):\n ...\n```\n\nBut the building block for that — failure-type introspection — doesn't exist yet. Rather than special-case it in the scheduled-tasks client, the framework primitive should land first.\n\n## Proposed API\n\nAdd to `durabletask.task.FailureDetails`:\n\n```python\ndef is_caused_by(self, error_type: str | type) -> bool:\n \"\"\"Return True if this failure's error_type matches `error_type`.\n\n Accepts either an exception type or its (qualified or unqualified) name.\n \"\"\"\n```\n\nDesign notes / open questions:\n- .NET matches by attempting to **load** the type named in `ErrorType` and checking assignability (base-type aware). Python could do something analogous (import the type and use `issubclass`), or a simpler/safer name-based match. Worth deciding how much \"load arbitrary type by name\" behavior we want, given the security posture of the rest of the SDK.\n- Python's `error_type` is the bare class name (e.g. `ScheduleInvalidTransitionError`), not namespace-qualified like .NET, so a name-based comparison is straightforward but won't disambiguate same-named types from different modules.\n- Should this also consider `InnerFailure`/chained causes once nested failure details are exposed?\n\n## Related\n\n- PR #160 (scheduled tasks) — discussion thread on flattening typed schedule exceptions to `RuntimeError`.\n- .NET reference: `src/Abstractions/TaskFailureDetails.cs`.\n\n## Out of scope\n\nReconstructing fully-typed exceptions (e.g. re-raising `ScheduleInvalidTransitionError` with its structured fields) is a separate, larger concern — the structured fields don't survive the orchestration boundary today (only the formatted message does), so that would need an additional `from_failure(message)`-style constructor convention. This issue is only about the `is_caused_by` introspection primitive.","author":{"url":"https://github.com/andystaples","@type":"Person","name":"andystaples"},"datePublished":"2026-06-29T19:12:18Z","url":"https://github.com/microsoft/durabletask-python/issues/162"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1d5acdaa-75ad-4f08-abb3-fdf7d3ef7d53 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DFB2:36B5:5D6EC4:7DD39A:6AFE4CB2 |
| html-safe-nonce | 86ae964e6ff3fb152c700924dae26fdc829aa96c6f68a1c5183ab4d43e0475f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkIyOjM2QjU6NUQ2RUM0OjdERDM5QTo2QUZFNENCMiIsInZpc2l0b3JfaWQiOiI1MjY5NzM5OTE5ODEwMzgzMDI2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 234ea3ecac7b6d091c3b50cb3098bf5fdb85a3a3aac56b2725a89417e86ae9de |
| hovercard-subject-tag | issue:4770899720 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/durabletask-python/162/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9a096072226e54463375244f628455cec0cb39a73538ab6d9a47a8102ee20aeb/microsoft/durabletask-python/issues/162 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9a096072226e54463375244f628455cec0cb39a73538ab6d9a47a8102ee20aeb/microsoft/durabletask-python/issues/162 |
| og:image:alt | Summary The .NET SDK exposes TaskFailureDetails.IsCausedBy |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andystaples |
| hostname | github.com |
| expected-hostname | github.com |
| None | 894d3c8b932306ed8425e8dcbe0c1089667e487c5fe7b8a05d17e7b685207429 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/durabletask-python git https://github.com/microsoft/durabletask-python.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 627664515 |
| octolytics-dimension-repository_nwo | microsoft/durabletask-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627664515 |
| octolytics-dimension-repository_network_root_nwo | microsoft/durabletask-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44570ad53e12be09be8000af683c29166c4007cb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width