Skip to content

Conversation

tconley1428
Copy link
Contributor

@tconley1428 tconley1428 commented Sep 3, 2025

What was changed

Switched to using a new code generated visitor for encoding and decoding workflow activations.
Notably, this will include encoding summaries, which were not previously encoded. This is a slightly breaking change, as it will result in encoded summaries for users who are using codecs without a codec server. In addition, we no longer use the encode_failure and decode_failure helpers. These weren't intended to be overridden to uniquely encode failure payloads, and aren't used everywhere.

Why?

We want to encode summaries.

Checklist

  1. Closes [Bug] Ensure every inbound and outbound workflow payload goes through codec #1071

  2. How was this tested:

  1. Any docs updates needed?

@tconley1428
Copy link
Contributor Author

I'm not currently trying to cover all message types, just the two needed for workflow activation. Others can be added later as needed when we want to expose this to users.

@tconley1428 tconley1428 marked this pull request as ready for review September 3, 2025 15:43
@tconley1428 tconley1428 requested a review from a team as a code owner September 3, 2025 15:43
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this implementation. I added a couple of minor comments.

Can we make a parenthetical next to the Python "TODO" at temporalio/features#468 to point to this PR for when that work is started? Also, I'd like @dandavison to take a peek here if possible, this is big enough to deserve an extra pair of eyes IMO. Part of me wonders if we should leave the existing logic around and let it be used if an env var is set at least for a release or two if we're afraid of behavior here, but that may be going too far.

for r in roots:
self.walk(r)

header = """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want something pretty visible here indicating that it's generated code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, fair

from temporalio.api.common.v1.message_pb2 import Payload
class VisitorFunctions(abc.ABC):
\"\"\"Set of functions which can be called by the visitor. Allows handling payloads as a sequence.\"\"\"
Copy link
Contributor

@dandavison dandavison Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python docstring law dictates that the first line shall have one sentence only and any subsequent sentences shall be separated by a newline from the first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe call it docstring suggestion if the docstring linter doesn't care, which it seemingly doesn't.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah not sure why that is. Regardless, it's the style we follow for public docstrings, so it's less distracting to just follow it everywhere. It's pretty ubiquitous

https://peps.python.org/pep-0008/#documentation-strings
https://peps.python.org/pep-0257/#multi-line-docstrings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't trying to say I wouldn't

Copy link
Contributor

@dandavison dandavison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge code cleanup and nice new utility!

It's obviously pretty involved and confirming correctness is going to come down to testing against a good range of inputs. The omes fuzzer could help give confidence. Also running the samples-python test suite against it. Let's discuss offline what more we're going to do before release.

@tconley1428 tconley1428 merged commit 634c5ec into main Sep 10, 2025
37 of 40 checks passed
@tconley1428 tconley1428 deleted the summary_encoding branch September 10, 2025 21:13
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] Ensure every inbound and outbound workflow payload goes through codec

3 participants