Skip to content

Add typed access to ApplicationError and CancelledError details - #2171

Open
prateek11rai wants to merge 1 commit into
temporalio:mainfrom
prateek11rai:application-error-typed-details
Open

prateek11rai wants to merge 1 commit into
temporalio:mainfrom
prateek11rai:application-error-typed-details

Conversation

@prateek11rai

Copy link
Copy Markdown
Contributor

Note

🤖 claude-opus-5-5 on behalf of Prateek

What was changed

Error details can now be read as your own type. Before, they always came back as plain values, so a dataclass detail was a dict.

except ActivityError as err:
    info = err.cause.detail(0, MyDataclass)  # MyDataclass, not a dict
  • ApplicationError and CancelledError get detail(index, type_hint) and raw_details (the detail payloads, None for errors created locally).
  • details is now decoded the first time it is read. It returns the same values as before.
  • from_failure keeps the payloads and the payload converter on the error instead of decoding them up front.
  • Both classes share this through a private base class, so their details property moved there.

I included CancelledError because its details are decoded the same way.

Not changed

TimeoutError.last_heartbeat_details is still decoded up front. It holds the activity's last heartbeat rather than error details, and #1262 is about ApplicationError. It can follow the same pattern in a separate PR.

Why?

#1262 asks for typed access to error details. Decoding when read also means one undecodable detail no longer loses the whole error (message, type, non_retryable); only reading that detail raises. The Go SDK works the same way: err.Details(&v) decodes on call.

Checklist

  1. Closes [Bug] Add ability to obtain ApplicationError details with type hint #1262

  2. How was this tested:

    New tests: round trips for both error types (typed read, decoded once, raw_details, IndexError), a locally created error, an undecodable detail, a Pydantic model, and end-to-end tests where the workflow, the client, and an async-cancelled activity read typed details through an encryption codec.

    test_previous_run_outcome_decodes_with_nexus_context now reads last_failure.details, because the detail is no longer decoded just by rebuilding the error.

  3. Any docs updates needed?

    Docstrings and added/ and changed/ changelog fragments. No README change: it only says an ApplicationError can include details. After a release, a short example of reading typed details on the Python error-handling page could help; I can open that docs PR.

details is now decoded when first read, and the new detail(index,
type_hint) decodes one detail with a type hint. from_failure keeps
the payloads and payload converter on the error instead of decoding
them up front.

Closes temporalio#1262

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Add ability to obtain ApplicationError details with type hint

1 participant