Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(converter): handle serialization of recursive exceptions #696

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion temporalio/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,8 @@ def to_failure(
str(exception), type=exception.__class__.__name__
)
failure_error.__traceback__ = exception.__traceback__
failure_error.__cause__ = exception.__cause__
if exception.__cause__ and exception.__cause__ != exception:
failure_error.__cause__ = exception.__cause__
self._error_to_failure(failure_error, payload_converter, failure)
# Encode common attributes if requested
if self._encode_common_attributes:
Expand Down
14 changes: 14 additions & 0 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,20 @@ async def decode(self, payloads: Sequence[Payload]) -> List[Payload]:
return list(wrapper.payloads)


async def test_broken_exception_serialization():
conv = DataConverter(
payload_codec=SimpleCodec(),
)
try:
try:
raise ValueError("test")
except Exception as e:
raise e from e
except Exception as e:
failure = Failure()
conv.failure_converter.to_failure(e, conv.payload_converter, failure)


async def test_failure_encoded_attributes():
try:
raise ApplicationError("some message", "some detail")
Expand Down