Hi guys
Is there any way to add a codec to the DataConverter without breaking determinism of existing long running workflows (that weren’t using the codec for data conversion)?
My codec is identical to the temporal example: https://github.com/temporalio/samples-python/blob/main/encryption/codec.py
And this is the code for the data converter
class PydanticPayloadConverter(CompositePayloadConverter):
"""Payload converter that replaces Temporal JSON conversion with Pydantic
JSON conversion.
"""
def __init__(self) -> None:
super().__init__(
*(
c
if not isinstance(c, JSONPlainPayloadConverter)
else PydanticJSONPayloadConverter()
for c in DefaultPayloadConverter.default_encoding_payload_converters
)
)
pydantic_data_converter = DataConverter(
payload_converter_class=PydanticPayloadConverter, payload_codec=EncryptionCodec()
)
When I add the codec and run the replayer for existing workflows that have not used the codec it fails with the error below.
When I run the replayer with a workflow that has used codec it works perfectly
This is the error
E RuntimeError: 4: Workflow activation completion failed: Failure { failure: Some(Failure { message: “Failed decoding arguments”, source: “”, stack_trace: " File "/usr/local/lib/python3.11/site-packages/temporalio/worker/_workflow_instance.py", line 301, in activate\n self._apply(job)\n\n File "/usr/local/lib/python3.11/site-packages/temporalio/worker/_workflow_instance.py", line 373, in _apply\n self._apply_resolve_activity(job.resolve_activity)\n\n File "/usr/local/lib/python3.11/site-packages/temporalio/worker/_workflow_instance.py", line 490, in _apply_resolve_activity\n ret_vals = self._convert_payloads(\n ^^^^^^^^^^^^^^^^^^^^^^^\n\n File "/usr/local/lib/python3.11/site-packages/temporalio/worker/_workflow_instance.py", line 1232, in _convert_payloads\n raise RuntimeError("Failed decoding arguments") from err\n", encoded_attributes: None, cause: Some(Failure { message: “‘Unknown payload encoding ’”, source: “”, stack_trace: " File "/usr/local/lib/python3.11/site-packages/temporalio/worker/_workflow_instance.py", line 1224, in _convert_payloads\n return self._payload_converter.from_payloads(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n File "/usr/local/lib/python3.11/site-packages/temporalio/converter.py", line 305, in from_payloads\n raise KeyError(f"Unknown payload encoding {encoding.decode()}")\n", encoded_attributes: None, cause: None, failure_info: Some(ApplicationFailureInfo(ApplicationFailureInfo { r#type: “KeyError”, non_retryable: false, details: None })) }), failure_info: Some(ApplicationFailureInfo(ApplicationFailureInfo { r#type: “RuntimeError”, non_retryable: false, details: None })) }), force_cause: Unspecified }
/usr/local/lib/python3.11/site-packages/temporalio/worker/_replayer.py:105: RuntimeError