Skip to content

Conversation

@romank0
Copy link
Contributor

@romank0 romank0 commented Oct 27, 2025

What was changed

This fixes the PayloadVisitor to properly handle failures with causes.

Why?

There is an issue when the custom codec is used. When the activity raises an exception with details a failure is properly encoded using a custom codc and is stored. But in the worker during the workflow activation the following error happens and workflow cannot proceed and eventually time outs:

Failed activation on workflow MyWorkflow with ID 9c556743-9ebf-4c3b-9800-3c56f02248a7 and run ID 3aeb4af6-97b6-43df-9c3e-a8b0f4326cd6
Traceback (most recent call last):
  File "..venv/lib/python3.11/site-packages/temporalio/worker/_workflow_instance.py", line 413, in activate
    self._apply(job)
  File "..venv/lib/python3.11/site-packages/temporalio/worker/_workflow_instance.py", line 512, in _apply
    self._apply_resolve_activity(job.resolve_activity)
  File "..venv/lib/python3.11/site-packages/temporalio/worker/_workflow_instance.py", line 769, in _apply_resolve_activity
    self._failure_converter.from_failure(
  File "..venv/lib/python3.11/site-packages/temporalio/converter.py", line 1096, in from_failure
    err.__cause__ = self.from_failure(failure.cause, payload_converter)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "..venv/lib/python3.11/site-packages/temporalio/converter.py", line 992, in from_failure
    *payload_converter.from_payloads_wrapper(app_info.details),
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "..venv/lib/python3.11/site-packages/temporalio/converter.py", line 139, in from_payloads_wrapper
    return self.from_payloads(payloads.payloads)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "..venv/lib/python3.11/site-packages/temporalio/converter.py", line 309, in from_payloads
    raise KeyError(f"Unknown payload encoding {encoding.decode()}")
KeyError: 'Unknown payload encoding binary/encrypted'

This happens because the PayloadVisito used in _WorkflowWorker._handle_activation does not visit cause field.

Checklist

  1. Closes [Bug] Failures in activites are not decoded in workflow when custom codec is used #1191

  2. How was this tested:

  • integration test in the PR
  • in real system with the approach similar to what is in the integration test
  1. Any docs updates needed?
    I don't think so.

@romank0 romank0 requested a review from a team as a code owner October 27, 2025 11:08
@tconley1428
Copy link
Contributor

Agreed on the bug. We can't take this fix however because _visitor.py is code generated as mentioned at the top of that file. The generator will have to be updated to account for this.

@tconley1428 tconley1428 merged commit 231cc67 into temporalio:main Oct 27, 2025
25 of 27 checks passed
tconley1428 added a commit that referenced this pull request Oct 27, 2025
* Adds proper failure decoding in workflow activation

* fixes formatting

* Update generator to include cause

---------

Co-authored-by: Tim Conley <[email protected]>
Co-authored-by: tconley1428 <[email protected]>
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] Failures in activites are not decoded in workflow when custom codec is used

2 participants